#include
#include
#include
int wait_flag;
void stop();
main() {
int pid1, pid2;
signal (3,stop);
while((pid1 = fork()) == -1);
if(pid1 > 0) {
while((pid2 = fork()) == -1);
if(pid2 > 0) {
wait_flag = 1;
sleep(5);
kill(pid1,16);
kill(pid2,17);
wait(0);
wait(0);
printf(“\n Parent process is killed !!\n”);
exit(0);
}
else {
wait_flag = 1;
signal(17,stop);
printf(“\n child process 2 is killed by parent !!\n”);
//输出“child process 2 is killed by parent !!”
exit(0);
}
}
else {
wait_flag = 1;
signal(16,stop);
printf(“\n child process 1 is killed by parent !!\n”);
exit(0);
}
}
void stop() {
wait_flag = 0;
}
这段代码编译运行后,终端跳出警告:在函数“main”中,隐式声明与内建函数“exit”不兼容。
我不知道怎么改,请高手帮我看看!谢谢!
我的编译代码是这样写的“gcc jincheng.c -o jincheng”

