Edit report at http://bugs.php.net/bug.php?id=37726&edit=1
ID: 37726 Comment by: bogdan at moongate dot ro Reported by: n dot escuder at intra-links dot com Summary: proc_open let fd opened in the child process Status: Bogus Type: Bug Package: Program Execution Operating System: Linux PHP Version: 5.1.4 Block user comment: N Private report: N New Comment: This *is* a bug. When you use fork(), the child process can still use (and more importantly, close) whatever sockets and handlers you had opened in the parent process. But when you use pcntl_open(), you start a new process from scratch, and the parent's sockets and handlers are not accessible. So you're basically inheriting useless garbage; if my assumptions above are correct then I don't see how this could not be a bug. However, if there are any scenarios where you would genuinely need/want to inherit those resources from the parent process then a PoC on how to access those resources in the child process would be very helpful. And even if that's the case, proc_open() should accept an additional parameter specifying whether they are needed or not. Finally, at the very least, the documentation should make it very clear that this is happening. I will have to rewrite a significant portion of a project I'm working on because I had no idea this was happening, and my child processes (which are not PHP) are inheriting the parent's listening sockets (which they will never need, never access, and cause trouble all around)... Previous Comments: ------------------------------------------------------------------------ [2006-09-09 13:43:58] [email protected] Please read what [email protected] said. No bug here. ------------------------------------------------------------------------ [2006-09-09 13:30:22] n dot escuder at intra-links dot com 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 ;) ------------------------------------------------------------------------ [2006-09-08 20:57:50] [email protected] 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. ------------------------------------------------------------------------ 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/bug.php?id=37726 -- Edit this bug report at http://bugs.php.net/bug.php?id=37726&edit=1
