#37726 [Bgs->Opn]: proc_open let fd opened in the child process
| From: | n dot escuder at intra-links dot com | Date: | Sat, 09 Sep 2006 13:30:23 +0000 |
| Subject: | #37726 [Bgs->Opn]: proc_open let fd opened in the child process | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-101928@lists.php.net to get a copy of this message | ||
ID: 37726
User updated by: n dot escuder at intra-links dot com
Reported By: n dot escuder at intra-links dot com
-Status: Bogus
+Status: Open
Bug Type: Program Execution
Operating System: Linux
PHP Version: 5.1.4
New Comment:
Hello,
When we create a child process on unix with fork and execl as php does
in proc_open we must cleanup all open fd execpt 0 1 2 before call execl
to have a clean child.
I think this is a bug because if in a script you open an sqlite query
ex: update ... and you start a proc_open the proc_open will have the fd
to the db dans the parent process will have a lock on the database.
Any childs process must not herit the parent fd's !
I use php cli version and start a lot of process system from an php
script parent and all child get all fd's from the parent ( connection
to database, files opened ... ).
This is not clean because all process are new process started by
proc_open and not pcntl_fork.
See You.
Escuder Nicolas
PS: I'm french so sorry for the traduction ;)
Previous Comments:
------------------------------------------------------------------------
[2006-09-08 20:57:50] tony2001@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
------------------------------------------------------------------------
[2006-06-26 07:55:39] n dot escuder at intra-links dot com
This is not the same in the bug #34794 the patch i see is only for new
opened descriptor and not all opened descriptor ( databases connections
... ).
In proc_open you use fork for creating a new child and change de
descriptor of STDIN STDOUT STDERR and after you do an exec.
Just before doing the exec you must close all open descriptor greater
than STDERR.
------------------------------------------------------------------------
[2006-06-25 17:51:36] jdolecek at NetBSD dot org
This may be the same problem as Bug #34794, which includes the fix.
------------------------------------------------------------------------
[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] nlopess@php.net
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.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/37726
--
Edit this bug report at http://bugs.php.net/?id=37726&edit=1