本港台最快开奖结果_本港台118kj开奖现场_明日大富翁开奖结果

[2019]本港台最快开奖结果是给大家带来了一个可以免费下载正版的机会,1本港台118kj开奖现场为玩家提供免费好玩的iPad游戏下载,点击明日大富翁开奖结果了解更多优惠信息,因为只有在注册之后下载下来的平台才是官方指定的。

经过间通讯

来源:http://www.alloutofdebt.com 作者:产品测评 人气:196 发布时间:2019-12-04
摘要:1、编写生龙活虎段程序,使用系统调用fork( 卡塔尔国创制七个子进度,再用系统调用signal(卡塔尔(英语:State of Qatar)让父进 程捕捉键盘上来的暂停时限信号(即按ctrl+c键),当捕捉到

1、编写生龙活虎段程序,使用系统调用fork( 卡塔尔国创制七个子进度,再用系统调用signal( 卡塔尔(英语:State of Qatar)让父进  程捕捉键盘上来的暂停时限信号(即按ctrl+c键),当捕捉到中断功率信号后,父进度用系统调用kill( 卡塔尔向三个子进度发出非功率信号,子进度捕捉到复信号后,分别出口下列音信后停下:  

Child process 1 is killed by parent!

Child process 2 is killed by parent!

父进度等待七个子进度终止后,输出以下音信后结束:

Parent process is killed!

 1 #include<stdio.h>
 2 #include<signal.h>
 3 #include<unistd.h>
 4 #include<sys/types.h>
 5 #include<sys/wait.h>
 6 int wait_mark;
 7 void waiting(),stop();
 8 void main()
 9 {int  p1, p2;
10 signal(SIGINT,stop);
11 while((p1=fork())==-1);
12 if(p1>0)                            /*在父进程中*/
13 {①
14 while((p2=fork())==-1);
15            If(p2>0)                    /*在父进程中*/
16             { ②
17                   wait_mark=1;
18                  waiting(0);
19                 kill(p1,10);
20                 kill(p2,12);
21                 wait( );
22                wait( );
23                printf("parent process is killed!n");
24                exit(0);
25             }
26            else                        /*在子进程2中*/
27            {
28 wait_mark=1;
29 signal(12,stop);
30 waiting();
31 lockf(1,1,0);
32 printf("child process 2 is killed by parent!n");
33 lockf(1,0,0);
34 exit(0);
35 }
36 } 
37 else                        /*在子进程1中*/
38 {
39       wait_mark=1;
40       signal(10,stop);
41       waiting();
42       lockf(1,1,0);
43       printf("child process 1 is killed by parent!n");
44       lockf(1,0,0);
45       exit(0);
46 }
47 }
48 void waiting()
49 {
50    while(wait_mark!=0);
51 }
52 void stop()
53 {
54    wait_mark=0;
55 }

 

⑴运路程序并解析结果。

^C

child process 2 is killed by parent!

child process 1 is killed by parent!

parent process is killed!

 

⑵假如把signal(SIGINT,stop卡塔尔(قطر‎放在①号和②号地方,结果会如何并深入分析原因。

1-

^C

child process 2 is killed by parent!

parent process is killed!

 

2-

^C

parent process is killed!

 

⑶该程序段前边部分用了多少个wait(0卡塔尔,为何?

关掉后一个wait

^C

child process 1 is killed by parent!

parent process is killed!root@kali:~/wyq/S4#

child process 2 is killed by parent!gcc -o S4_1-3.out S4_1-3.c

 

七个都关掉

^C

parent process is killed!root@kali:~/wyq/S4#

child process 2 is killed by parent!

child process 1 is killed by parent!^C

本文由本港台最快开奖结果发布于产品测评,转载请注明出处:经过间通讯

关键词:

频道精选

最火资讯