ID: 37726 Comment by: jdolecek at NetBSD dot org Reported By: n dot escuder at intra-links dot com Status: Open Bug Type: Program Execution Operating System: Linux PHP Version: 5.1.4 New Comment:
This may be the same problem as Bug #34794, which includes the fix. Previous Comments: ------------------------------------------------------------------------ [2006-06-07 17:08:45] n dot escuder at intra-links dot com Yes when we do a pcntl_fork or a fork in C the FD must stay open but here it's a complety new program that is started. Proc_open use fork for starting the new process but don't cleanup open descriptor after the fork. ------------------------------------------------------------------------ [2006-06-07 15:16:24] [EMAIL PROTECTED] IMHO, I think this is expected. When you fork under unix the open file descriptors will be copied to the child process. proc_open just enforces what the specified fd should look like. ------------------------------------------------------------------------ [2006-06-07 10:56:45] n dot escuder at intra-links dot com Description: ------------ When executing a program with proc_open the child process that is started by proc_open have all fd's that was opened in the master script ex: file, database connection .... The child process must don't have any fd open expect the fd specified by $descriptorspec. Reproduce code: --------------- <? $fd = fopen("/tmp/test.log", "w"); $descriptorspec = array( 0 => array("pipe", "r"), 1 => array("pipe", "w"), 2 => array("pipe", "w") ); $pipes = null; $process = proc_open("ls /proc/self/fd -l", $descriptorspec, $pipes); while ( ( $line = fgets($pipes[1]) ) ) { echo $line; } proc_close( $process ); fclose($fd ); ?> Expected result: ---------------- total 5 lr-x------ 1 root root 64 2006-06-07 12:44 0 -> pipe:[22573] l-wx------ 1 root root 64 2006-06-07 12:44 1 -> pipe:[22574] l-wx------ 1 root root 64 2006-06-07 12:44 2 -> pipe:[22575] lr-x------ 1 root root 64 2006-06-07 12:44 3 -> /proc/19964/fd Actual result: -------------- total 5 lr-x------ 1 root root 64 2006-06-07 12:44 0 -> pipe:[22573] l-wx------ 1 root root 64 2006-06-07 12:44 1 -> pipe:[22574] l-wx------ 1 root root 64 2006-06-07 12:44 2 -> pipe:[22575] l-wx------ 1 root root 64 2006-06-07 12:44 3 -> /tmp/test.log lr-x------ 1 root root 64 2006-06-07 12:44 4 -> /proc/19964/fd ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=37726&edit=1