|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull Requests |
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 06:00:02 2025 UTC |
Description: ------------ PHP process do not quit. By some way it is waiting the process created by proc_open to close. Sending a Ctrl-C send a signal to PHP process and both die. If I launch it as a background process( appending to command & ) it return the wrong pid( maybe the parent pid of something that proc_open called ) but PHP do not lock. The process PID of executable is the pid + 1 returned. THe problem is that this PID + 1 remains alive. The option bypass_shell is documented for windows only. Expect this not to be a duplicated bug or bad interpretation of function instructions manual. Test script: --------------- <?php define( 'LF', "\n" ); $statusI = 0; $processIO = array( 0 => array( 'pipe', 'r' ) # client process will read from it. This process will write to it # ,1 => array( 'pipe', 'w' ) ,2 => array( 'pipe', 'w' ) ); $procPipes = array(); #$processIO = array(); $proc = proc_open( '/bin/netstat -ic ', $processIO, $procPipes, getcwd(), null, array( 'bypass_shell' => true, 'binary_pipes' => true ) ); #var_dump( $procPipes ); #/* if ( !$statusI ) { $status = proc_get_status( $proc ); if ( !$status['running'] ) $statusI = $status['exitcode']; } #*/ print( LF.'PHP ps pid: '.posix_getpid() ); print( LF.'Child ps pid: '.$status['pid'] ); #/* fclose( $procPipes[0] ); fclose( $procPipes[1] ); fclose( $procPipes[2] ); #*/ #var_dump( __LINE__, proc_close( $proc ) ); $procPipes = null; $proc = null; exit( LF.'PHP dying.' ); ?> Expected result: ---------------- Expected that PHP launchs another separated process do his own tasks and exit leaving the other process alive. Appending the & to the command unblock but returns the wrong pid. Actual result: -------------- Got a blocked PHP process. Example: PHP ps pid: 13658 Child ps pid: 13659 ( blocked here ). ps -o pid,ppid,cmd,stat 13659 PID PPID CMD STAT 13659 13658 /bin/netstat -ic S+ Terminating PHP pid finish the other process too. With & at end. Example: PHP ps pid: 13724 Child ps pid: 13725 PHP dying. ps -o pid,ppid,cmd,stat 13725 PID PPID CMD STAT ps -o pid,ppid,cmd,stat 13726 ( process 1 init as parent ) PID PPID CMD STAT 13726 1 /bin/netstat -ic S