Browse files

phpsh spawned php processes should not ignore SIGPIPE

python by default ignores SIGPIPE, this setting transfers to child
processes, causing some php processes to not exit in certain cases and
instead waste CPU. This resets the SIGPIPE signal handler to default,
which will kill the process when the pipe is gone.
  • Loading branch information...
1 parent 00c4de3 commit b9ab98cdad4fca560efd7fb2a60daf550006d9e6 Yiding Jia committed with adonohue Jul 27, 2010
Showing with 4 additions and 0 deletions.
  1. +4 −0 src/phpsh.php
4 src/phpsh.php
@@ -501,6 +501,10 @@ function undefined_function_check($buffer) {
function interactive_loop() {
+ // python spawned-processes ignore SIGPIPE by default, this makes sure
+ // the php process exits when the terminal is closed
+ pcntl_signal(SIGPIPE,SIG_DFL);
while (!feof($this->_handle)) {
// indicate to phpsh (parent process) that we are ready for more input
fwrite($this->_comm_handle, "ready\n");

0 comments on commit b9ab98c

Please sign in to comment.