vendredi 29 juillet 2016

If I set signal(SIGCHLD, SIG_IGN); to avoid zombies - system() returns -1 and "No child processes"

I have a simple server which does fork for a new socket connection. If I set signal(SIGCHLD, SIG_IGN); to avoid zombies when I call system() in child process to execute needed script - everything is executed fine but seems like child gets removed from table of processes before it exited, so it's strange. Here is the example of output:

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 

Aucun commentaire:

Enregistrer un commentaire