Chinaunix首页 | 论坛 | 博客
  • 博客访问: 689406
  • 博文数量: 214
  • 博客积分: 5015
  • 博客等级: 大校
  • 技术积分: 2285
  • 用 户 组: 普通用户
  • 注册时间: 2006-06-18 17:02
文章分类

全部博文(214)

文章存档

2008年(43)

2007年(171)

我的朋友

分类:

2007-11-27 16:43:52

#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>

int main()
{
   pid_t pid;
   
   /* Remove the defunc pid in process table */
   signal(SIGCLD, SIG_IGN);

   while(true)
   {
      switch(pid=fork())
      {
         case -1:
           printf("Fork failured!\n");
           break;
         case 0:
           printf("This is child thread!\n");
           _exit(0);
           break;
         default:
           printf("Child process %d created!\n", pid);
           sleep(10);
           break;
      }
   }
}

以前总是没有写signal一行.

阅读(853) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~