标题:wait隐式函数有什么问题,一直有警告
只看楼主
源哥。。。
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2017-11-13
结帖率:0
 问题点数:0 回复次数:0 
wait隐式函数有什么问题,一直有警告
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <unistd.h>

void waiting(),stop();
int wait_mark;

void main() {
  int p1,p2;
  if (p1=fork()) {                /*创建子进程 p1*/
      if (p2=fork()) {            /*创建子进程 p2*/
         wait_mark=1;
         signal(SIGINT,stop);    /*接收到^c 信号,转 stop*/
         waiting();
         kill(p1,16);            /*向 p1 发软中断信号 16*/
         kill(p2,17);            /*向 p2 发软中断信号 17*/
         wait(0);               /*同步*/
         wait(0);
         printf("Parent process is terminated!\n");
         exit(0);
       }
       else {
           wait_mark=1;   
           signal(SIGINT,stop);
           waiting();
           lockf(1,0,0);
           printf("Child process2 is killed by parent!\n");
           lockf(1,0,0);
           exit(0);
        }
     }
     else  {
         wait_mark=1;
signal(SIGINT,stop);
         waiting();
         lockf(1,0,0);
         printf("Child process1 is killed by parent!\n");
         lockf(1,0,0);
         exit(0);
      }
}
void waiting()  {
while (wait_mark!=0);
}
void stop()  {
wait_mark=0;
}
搜索更多相关主题的帖子: wait include void printf Parent 
2019-04-27 10:28



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-494439-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.051470 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved