#include<stdio.h>
#include<stdlib.h>
#include<signal.h>
#include<sys/types.h>
#include<sys/wait.h>
#include<unistd.h>
int main()
{
pid_t result;
int ret,newret;
result=fork();
if(result<0)
{
perror("fork error");
exit(1);
}
if(!result)
{
raise(SIGSTOP);
exit(0);
}
else
{
printf("child pid:%d\n",result);
if(!waitpid(result,NULL,WNOHANG))
{
if(ret=kill(result,SIGKILL)==0)
printf("ret:%d,result:%d\n",ret,result);
else
perror("kill error");
}
}
}
为什么ret最后值为1
程序运行后显示:
child pid:3434
ret:1,result:3434
(ret=kill(result,SIGKILL))==0
了解一下运算符优先级