- 论坛徽章:
- 0
|
#include
#include
#include
#include
void sig_child(int signo )
{
pid_t pid ;
int stat ;
sdvsdcv
//
while ( (pid = waitpid(-1 , &stat ,WNOHANG)) >0 )
printf( "pid : %d" , pid ) ;
return ;
}
int main( void )
{
signal(SIGCHLD , sig_child );
int pid;
//int pid2;
//printf("%d ",getppid());
printf("=============\n");
printf("LLLLLLLLLLLLL");
if((pid=fork())==0){
printf("This is the child process:%d\n",pid);
}
else
{ int a = 65535 ;
while( a ) a-- ;
sleep(10);
/*
if((pid2=fork())==0)
printf("This is another child process:%d\n ",pid2);
else
printf("This is the parent process:%d %d\n",pid,pid2);
*/
}
printf("--------\n");
return 1;
}
本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u3/102778/showart_2029945.html |
|