linux c 唤醒进程 获取子进程结束状态

void don(int sig)
        {

      printf("rece sig %d\n");
        }
void testwake()
{
    int pid;
    int p=getpid();
    pid=fork();
    if(pid==0){
        printf("child before\n");
        sleep(3);
        kill(p,SIGUSR1);

    }else{
        signal(SIGUSR1,don);
        sleep(30);//pause();
        printf("go on\n");

    }
}

pid_t pid;
pid = fork();
if(pid==0){
//child

//exit(88);//正常退出

char* ex;
strcpy(ex,"aaa");

}else{

int status;
wait(&status);
if (WIFEXITED(status)) {
            printf("exited, status=%d\n", WEXITSTATUS(status));

                   }else{
printf("abnormal exit!\n");
}


}
posted on 2010-07-07 21:38  yangyh  阅读(1855)  评论(0编辑  收藏  举报