×¢Ò⣺Ҫ½øÐÐ×Ó½ø³ÌµÄ²¢·¢¿ØÖÆ£¬ÒÔÃâÁ½¸ö½ø³ÌµÄÊä³ö½á¹û½»Ö¯ÔÚÒ»Æð¡£
³ÌÐò£º#include
#include
#include
#include
void child_function_one()
{
while(1)
{
printf("Hello ! I am subprogram 1! \n");
//kill(getpid(),SIGUSR1);
sleep(5);
}
//puts("Good bye! \n");
//exit(0);
}
void child_function_two()
{
while(1)
{
printf("Hello ! I am subprogram 2! \n");
//kill(getpid(),SIGUSR2);
sleep(5);
}
//puts("Good bye! \n");
//exit(0);
}
void main()
{
pid_t p1, p2;
p1=fork();
if (p1==0)
{
child_function_one();
}
p2=fork();
if (p2==0)
{
child_function_two();
}
sleep(10000);
kill(p1,SIGKILL);
kill(p2,SIGKILL);
}