- 论坛徽章:
- 0
|
谢谢,但是信号好像会丢失,并且qt里的signal,slot可以发送变量,但是kill不可以传送值给父进程
#include <signal.h>
#include <sys/types.h>
#include <stdio.h>
#include <stdlib.h>
void sig_handle(int signum)
{
if(signum==10){
printf("i'm handle and pid=%d\n",getpid());
sleep(1);
}
}
int main(int argc,char *argv[])
{
pid_t child;
signal(10,sig_handle);
child=fork();
if(child==0)
{
sleep(2);
printf("i'm child and pid=%d\n",getpid());
int i=10;
while(i--){
kill(getppid(),10);
}
sleep(1000);
}
printf("i'm parent and pid=%d\n",getpid());
while(1){
sleep(2);
}
return 0;
}
|
[ 本帖最后由 john.daker 于 2008-11-13 23:08 编辑 ] |
|