ChinaUnix.net
相关文章推荐:

linux dbusdaemon system fork

system 函数和有同等机能的函数(mysystem)的示例。 execlp(execvp,..)函数一实行参数的命令和指定参数就将执行,但是执行后,相应程序将终止。 如果想在其执行后,仍继续进行程序处理动作,就要通过fork生成子进程,在那个子进程内执行execlp等命令。execlp函数执行结束后,即使子进程终了后,其父进程仍然能够继续执行相应处理。 execlp 函数中,用通常的shell执行pipe和Redirection处理( | etc.)和通过正规表现(? * etc.)不...

by bo_00 - Linux文档专区 - 2009-07-10 22:40:02 阅读(2110) 回复(0)

相关讨论

两个问题,请大家一起讨论。 1、fork和exec系列调用前后,进程在内存的“数据段”,“堆栈段”和“代码段”有什么不同?除此以外,fork和exec系列调用还有什么区别? 2、system和popen有什么区别?都常用在什么场合?

by 蓝色键盘 - C/C++ - 2006-10-12 16:19:00 阅读(19641) 回复(34)

/******************************************************************************* * 版权所有 (C)2009 mycareer * 系统名称 : myfork * 文件名称 : myfork.cpp * 内容摘要 : 测试fork创建的子进程与父进程是否共享的数据段 * 当前版本 : 1.0 * 作 者 : mycareer * 设计日期 : 2009年7月21日 * 修改记录 : * 日 期 版 本 修改人 修改摘要 *******************************************************************************/ ...

by istvh - Linux文档专区 - 2009-07-26 08:58:04 阅读(525) 回复(0)

/******************************************************************************* * 版权所有 (C)2009 mycareer * 系统名称 : myfork * 文件名称 : myfork.cpp * 内容摘要 : 测试fork创建的子进程与父进程是否共享的数据段 * 当前版本 : 1.0 * 作 者 : mycareer * 设计日期 : 2009年7月21日 * 修改记录 : * 日 期 版 本 修改人 修改摘要 *******************************************************************************...

by mycareer - Linux文档专区 - 2009-07-21 20:49:28 阅读(494) 回复(0)

本帖最后由 c513636054 于 2010-12-01 10:52 编辑 int main(void) { int pid=0; printf("======>[%d]\n", getpid() ); while( pid = fork() < 0 ); printf("------>[%d]\n", getpid() ); printf("pid = [%d]\n", pid ); if ( pid == 0 ) printf("this's subprocess\n"); if ( pid > 0 ) printf( "this's father process\n" ); return 0; } 远行结果为: ======>[30962] ------>[...

by c513636054 - C/C++ - 2010-12-01 11:37:58 阅读(1880) 回复(7)

int main(void) { int pid=0; printf("======>[%d]\n", getpid() ); while( pid = ( fork() < 0 ) ); printf("------>[%d]\n", getpid() ); printf("pid = [%d]\n", pid ); if ( pid == 0 ) printf("this's subprocess\n"); if ( pid > 0 ) printf( "this's father process\n" ); return 0; } 远行结果为: ======>[30962] ------>[30963] pid = [0] this's subprocess pid = [0] th...

by c513636054 - Linux环境编程 - 2010-12-01 12:50:16 阅读(1346) 回复(4)

求教,源程序如下(t1.c): #include #include #include int main() { pid_t child = 0; int i,n; i = 0; n = 0; printf("%d befor %d\n",getpid(),i); if((child = fork()) <= 0) goto App; else printf("%d:%d,产生的child进程号为[%d]\n",getpid(),i,child); App: printf("mypid is %d,my i is %d,my father is %d,my child is %d\n",getpid(),i,getppid(),child); ret...

by sdaubin - C/C++ - 2010-08-12 18:36:41 阅读(1493) 回复(4)

在编写socket ftp之前,我对fork函数进行了学习。 先看这段范例代码: #include unistd.h>; #include sys/types.h>; main () { pid_t pid; pid=fork(); if (pid 0) printf("error in fork!"); else if (pid == 0) printf("i am the child process, my process id is %dn",getpid()); else p...

by jimylion - Linux文档专区 - 2009-08-06 19:48:10 阅读(690) 回复(0)

在编写socket ftp之前,我对fork函数进行了学习。 先看这段范例代码: #include unistd.h>; #include sys/types.h>; main () { pid_t pid; pid=fork(); if (pid 0) printf("error in fork!"); else if (pid == 0) printf("i am the child process, my process id is %dn",getpid()); else p...

by jimylion - Linux文档专区 - 2009-08-06 19:48:10 阅读(718) 回复(0)

#include #include #include int main() { pid_t pid; static int n = 0; printf("fork!\n"); /*printf("fork!")*/ switch (pid = fork()) { case -1: { /* 这里pid为-1,fork函数失败 */ /* 一些可能的原因是 */ /* 进程数或虚拟内存用尽 */ perror("The fork failed!"); break; } case 0: { ...

by tancotq - Linux文档专区 - 2009-07-07 18:47:59 阅读(693) 回复(0)

在编写socket ftp之前,我们先学习fork函数 先看这段范例代码: #include unistd.h>; #include sys/types.h>; main () { pid_t pid; pid=fork(); if (pid 0) printf("error in fork!"); else if (pid == 0) printf("i am the child process, my process id is %dn",getpid()); else printf("i am the parent process, my process id is %dn",getpid()); } 这段代码写了一个使用...

by iceway - Linux文档专区 - 2008-08-13 09:22:26 阅读(645) 回复(0)