ChinaUnix.net
相关文章推荐:

linux fork

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

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

相关讨论

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

by mycareer - Linux文档专区 - 2009-07-21 20:49:28 阅读(606) 回复(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 阅读(2006) 回复(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 阅读(1485) 回复(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 阅读(1601) 回复(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 阅读(787) 回复(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 阅读(825) 回复(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 阅读(784) 回复(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 阅读(720) 回复(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 rambo123 - Linux文档专区 - 2008-05-18 14:03:31 阅读(560) 回复(0)

进程配置有唯一的进程控制块PCB,由proc结构和usr结构组成。 下面依次介绍进程相关的系统调用: 1:fork()函数 创建一个子进程 #include /* 提供类型pid_t的定义 */ #include /* 提供函数的定义 */ pid_t fork(void); 只看fork的名字,可能难得有几个人可以猜到它是做什么用的。fork系统调用的作用是复制一个进程。当一个进程调用它,完成后就出现两个几乎一模一样的进程,我们也由此得到了一个新进程。据说fork的名...

by kim_fifi - Linux文档专区 - 2007-11-18 14:47:08 阅读(644) 回复(0)