大侠们帮着看看这段程序那里出错了!!谢谢了!
#include<stdio.h>#include<signal.h>
#include<unistd.h>
#include<sys/types.h>
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");
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;
}
为什么系统总说第五行和第六行有错误?
line 5: int: command not found
line 6: syntax error near unexpected token `('
line 6: `void stop();'
我没觉着哪里不对呀?
我是在红旗Linux下的vi中运行的.