PHP 8.5.0 Alpha 4 available for testing

Voting

: min(five, three)?
(Example: nine)

The Note You're Voting On

wally at soggysoftware dot co dot uk
9 years ago
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.

<< Back to user notes page

To Top