note 119246 added to function.pcntl-signal
| From: | wally at soggysoftware dot co dot uk | Date: | Tue, 26 Apr 2016 12:27:33 +0000 |
| Subject: | note 119246 added to function.pcntl-signal | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-205337@lists.php.net to get a copy of this message | ||
A word of caution around the third parameter (restart_syscalls) in pcntl_signal(...).
I kept having a repeated issue where (seemingly randomly) my script would "exit
unexpectedly" (_exit_, not crash: the exit code was always 0) while tracking forked children
using signal handlers.
It appears that the signal handling is not at fault (indeed, PHP isn't "at fault").
Having "restart_syscalls" set to FALSE seemed to be the problem's cause.
I haven't debugged the issue extensively - except to observe that the issue was highly
intermittent and seemed to relate to my use of usleep() in conjunction with restart_syscalls=FALSE.
My theory is the usleep() was wrongly tracking time - as described over here: http://man7.org/linux/man-pages/man2/restart_syscall.2.html
Long story short, I re-enabled (which is the default value) restart_syscalls, and the issue went
away.
If you're curious - register_shutdown_function was still being handled correctly - so PHP
definitely was _NOT_ crashing. Interestingly however, my procedural code never "resumed"
after the signal was handled.
I do not believe this is a bug. I believe it was ignorant user error. YMMV.
----
Server IP: 72.52.91.14
Probable Submitter: 46.227.55.4
----
Manual Page -- http://php.net/manual/en/function.pcntl-signal.php
Edit -- https://master.php.net/note/edit/119246
Del: integrated -- https://master.php.net/note/delete/119246/integrated
Del: useless -- https://master.php.net/note/delete/119246/useless
Del: bad code -- https://master.php.net/note/delete/119246/bad+code
Del: spam -- https://master.php.net/note/delete/119246/spam
Del: non-english -- https://master.php.net/note/delete/119246/non-english
Del: in docs -- https://master.php.net/note/delete/119246/in+docs
Del: other reasons-- https://master.php.net/note/delete/119246
Reject -- https://master.php.net/note/reject/119246
Search -- https://master.php.net/manage/user-notes.php