|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #53085 Php blocked waiting process exit
Submitted: 2010-10-16 23:49 UTC Modified: -
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (100.0%)
From: sumariva at gmail dot com Assigned:
Status: Open Package: Program Execution
PHP Version: 5.2.14 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: sumariva at gmail dot com
New email:
PHP Version: OS:


 [2010-10-16 23:49 UTC] sumariva at gmail dot com
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:
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


Add a Patch

Pull Requests

Add a Pull Request

PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 20 19:01:28 2024 UTC