linux c函数kill返回值的问题

#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

阅读 4.6k
1 个回答

(ret=kill(result,SIGKILL))==0

了解一下运算符优先级

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题