#include
#include
#include
#include
#include
#include
void fun(int sig)
{
kill(0 , SIGKILL );
}
int main( void )
{
int pid = 0;
if( pid = fork() )
{
fflush( stdout );
sleep ( 5 );
printf ( "kill ( pid, SIG ); \n");
fflush( stdout );
kill ( pid, SIGUSR1 );
sleep ( 10 );
printf ( "the father is still alive!\n", pid );
fflush( stdout );
}
else
{
setpgid(0,0);
signal( SIGUSR1, fun );
if( pid = fork() )
{
int i = 10;
while ( i-- )
{
fflush( stdout );
sleep ( 1 );
}
}
else
{
int i = 10;
while ( i-- )
{
printf ( "in grandsun , pid= %d\nin grandsun , ppid= %d\n", getpid(), getppid() );
fflush( stdout );
sleep ( 1 );
}
}
}
return 0;
}
阅读(877) | 评论(0) | 转发(0) |