Search code examples
phpsignalspcntl

PHP PCNTL - what does pcntl_signal()'s restart_syscalls parameter do?


I've been using PHP's PCNTL extension for a little while now, but can't figure out what the restart_syscalls parameter of pcntl_signal() does. I tried looking around the Internets, but couldn't find any information. All the documentation says is:

"Specifies whether system call restarting should be used when this signal arrives."

What is "system call restarting"?


Solution

  • Suppose you programmed your signal handler to stop a process using signals like:

    • SIGTERM: to terminate a process; it can be blocked, handled, and ignored unlike SIGKILL.
    • SIGKILL: to immediately terminate a process
    • SIGSTOP: to pause the process in its current state

    restart_syscalls specifies whether system call restarting should be used when signo arrives. Examples of signo are the three I listed above and there are much more.

    This means, if restart_syscalls is set to the default value TRUE, this will restart certain system calls after a process that was stopped by a signal signo. It restarts the interrupted system call with a time argument that is suitably adjusted to account for the time that has already elapsed.

    I forward you to this very simple and clear example: pcntl_wait not interrupted by SIGTERM