php.net |  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: -
Votes:1
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
Have you experienced this issue?
Rate the importance of this bug to you:

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


Patches

Add a Patch

Pull Requests

Add a Pull Request

 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Mon Sep 16 06:01:27 2019 UTC