#include<stdio.h>
#include<signal.h>
#include<unistd.h>
#include<stdlib.h>
int wait_mark;
void waiting(), stop();
int main(int argc, char *argv[])
{
int p1, p2;
signal(SIGINT, stop);
while((p1 = fork()) == -1);
if (p1 > 0) /*在父进程中*/
{①
while((p2 = fork()) == -1);
if (p2 > 0) /*在父进程中*/
{②
wait_mark = 1;
waiting();
kill(p1, 10);
kill(p2, 12);
wait(NULL);
wait(NULL);
printf("parent process exit!\n");
exit(0);
}
else /*在子进程 2 中*/
{
wait_mark = 1;
signal(12, stop);
waiting();
lockf(1, 1, 0);
printf(&#
Linux环境下使用signal函数进行进程间通信的问题
最新推荐文章于 2023-11-20 22:43:39 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)