| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
共有 742 人关注过本帖
标题:vfork的使用
取消只看楼主 加入收藏
pauljames
Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19
等 级:千里冰封
威 望:9
帖 子:1555
专家分:10000
注 册:2011-5-8
结帖率:88.89%
收藏
已结贴  问题点数:30 回复次数:0 
vfork的使用
关于vfork,如果我在子进程里面不调用exit(),那么就会不断的创建进程,直到到达进程最大限制后报错;而fork没有这个问题,不知道是什么原因,请大家指点。代码贴上
#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>
int main (void)
{
   int count = 1;
   int child;
   printf("Before create son, the father's count is:%d\n", count);
   child = vfork();
   if(child < 0)
     {
        printf("error in vfork!");
        exit(1);
      }
   if(child==0)
     {
        printf("This is son\n");
        //exit(1);
     }
   else
     {
        printf("After son, This is father\n");

     }
   return 0;
}

[ 本帖最后由 pauljames 于 2012-8-18 20:50 编辑 ]

经常不在线不能及时回复短消息,如有c/单片机/运动控制/数据采集等方面的项目难题可加qq1921826084。
2012-08-18 20:48
快速回复:vfork的使用
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.012823 second(s), 8 queries.
Copyright©2004-2025, BC-CN.NET, All Rights Reserved