Signals in Extensions

php.internals

Michael B Allen

20 years ago
I have an extension that interfaces with a library that sets a signal handler for some common signals. In particular the library forks processes and does socket writes so it needs to be able to handle SIGCHLD and SIGPIPE. It also registers some other signals for debugging purposes. Can I anticipate any kinds of problems from this? Does the Zend engine use any signals in particular? Thanks, Mike

Sara Golemon

20 years ago
> I have an extension that interfaces with a > library that sets a signal handler for some > common signals. In particular the library > forks processes and does socket writes > so it needs to be able to handle SIGCHLD > and SIGPIPE. It also registers some other > signals for debugging purposes. Can I > anticipate any kinds of problems from this? > Does the Zend engine use any signals in particular? >
It's not PHP/Zend you should be afraid of... the interpreter goes a long way towards avoiding the use of signals because it's designed to run on <whatever> webserver and that webserver may or may not try to use signals in one way or another. If you're using the CGI SAPI you might be safe, other than that.... Best of luck to ya.

Rasmus Lerdorf

20 years ago
Sara Golemon wrote:
>> I have an extension that interfaces with a >> library that sets a signal handler for some >> common signals. In particular the library >> forks processes and does socket writes >> so it needs to be able to handle SIGCHLD >> and SIGPIPE. It also registers some other >> signals for debugging purposes. Can I >> anticipate any kinds of problems from this? >> Does the Zend engine use any signals in particular? >> > It's not PHP/Zend you should be afraid of... the interpreter goes a long way > towards avoiding the use of signals because it's designed to run on > <whatever> webserver and that webserver may or may not try to use signals in > one way or another. If you're using the CGI SAPI you might be safe, other > than that.... Best of luck to ya.
Well, we do need SIGALRM for timeouts, but yes, beyond that we should be signal-clean. But as Sara says, PHP is usually embedded inside something else and that something else tends to use signals for all sorts of stuff. -Rasmus