如果我设置信号(SIGCHLD,SIG_IGN);避免僵尸 - system()返回-1和"没有子进程"

时间:2015-01-20 17:13:25

标签: c client-server system zombie-process sigchld

我有一个简单的服务器,它为新的套接字连接做fork。 如果我在调用signal(SIGCHLD, SIG_IGN);时设置system()以避免僵尸 在子进程中执行所需的脚本 - 一切都执行得很好,但似乎孩子在退出之前从进程表中删除,所以很奇怪。以下是输出示例:

server started. version 0.20
opening socket 
binding 
listening 
parent process does nothing
client message: print.php
executing php script: "print.php" 
full command line of execution: "php print.php" <-- we call system() which executes php script on server
Hello, World!                      <-- this is output of php script
return value from script execution: -1      <-- should be ok but -1 instead
system returns -1 error: No child processes
child is closing socket 

0 个答案:

没有答案