红联Linux门户
Linux帮助

我编写的代码运行时碰到问题,请大家帮我看看,很急!谢谢

发布时间:2009-05-29 20:43:03来源:红联作者:liulisuli
我是在VMware上安装了RedHat Linux 5 ,现在在写了两段代码编译后,终端说有错误和警告,无法运行,请大家帮忙解决下好吗?
#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”
文章评论

共有 0 条评论