I use pcntl_fork to start a child process to send email through SMTP.
The child process uses the PEAR Mail package to send e-mail, but the problem is that the remote server is not responding, the process just runs forever, waiting for a response, regardless of any time limit set in php.ini.
To get around this, I use the pcntl_alarm function to run the function after 30 seconds, which kills the child process if it is still running.
function handlesig($sig) { global $pid,$node,$resend; posix_kill($pid,SIGKILL); mysql_query("insert into log (event) values ('Timed out!')"); }
When I kill a child process, although I remain with a non-existent process in the system.
Is there any other signal I should use that will still cause the child process to die without waiting for the connection (because the connection will never end) and avoid the growth of non-existent processes?
linux php posix
Tim
source share