xinhao

来源:互联网 发布:简明python教程 中文 编辑:程序博客网 时间:2024/06/06 00:26
#include <stdio.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <signal.h>
#include <unistd.h>


int main()
{
    pid_t pid;
    int status;
    if (!(pid = fork()))
    {
        printf("hi , i child process\n");
sleep(10);
return;
    }
    else
    {
        printf("send signal to child %d\n", pid);
sleep(1);
kill(pid, SIGABRT);
wait(&status);
if(WIFSIGNALED(status))
   printf("child recive %d\n", WTERMSIG(status));
    }
}
原创粉丝点击