nlopess         Tue Feb 13 19:56:42 2007 UTC

  Modified files:              
    /php-src/ext/standard       proc_open.c 
    /php-src/ext/standard/tests/general_functions       bug34794.phpt 
  Log:
  MFB
  
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/proc_open.c?r1=1.51&r2=1.52&diff_format=u
Index: php-src/ext/standard/proc_open.c
diff -u php-src/ext/standard/proc_open.c:1.51 
php-src/ext/standard/proc_open.c:1.52
--- php-src/ext/standard/proc_open.c:1.51       Tue Jan  9 16:27:32 2007
+++ php-src/ext/standard/proc_open.c    Tue Feb 13 19:56:42 2007
@@ -15,7 +15,7 @@
    | Author: Wez Furlong <[EMAIL PROTECTED]>                           |
    +----------------------------------------------------------------------+
  */
-/* $Id: proc_open.c,v 1.51 2007/01/09 16:27:32 dmitry Exp $ */
+/* $Id: proc_open.c,v 1.52 2007/02/13 19:56:42 nlopess Exp $ */
 
 #if 0 && (defined(__linux__) || defined(sun) || defined(__IRIX__))
 # define _BSD_SOURCE           /* linux wants this when XOPEN mode is on */
@@ -945,6 +945,10 @@
                                                        
descriptors[i].mode_flags), mode_string, NULL);
 #else
                                stream = 
php_stream_fopen_from_fd(descriptors[i].parentend, mode_string, NULL);
+# if defined(F_SETFD) && defined(FD_CLOEXEC)
+                               /* mark the descriptor close-on-exec, so that 
it won't be inherited by potential other children */
+                               fcntl(descriptors[i].parentend, F_SETFD, 
FD_CLOEXEC);
+# endif
 #endif
                                if (stream) {
                                        zval *retfp;
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/general_functions/bug34794.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/general_functions/bug34794.phpt
diff -u /dev/null php-src/ext/standard/tests/general_functions/bug34794.phpt:1.2
--- /dev/null   Tue Feb 13 19:56:42 2007
+++ php-src/ext/standard/tests/general_functions/bug34794.phpt  Tue Feb 13 
19:56:42 2007
@@ -0,0 +1,34 @@
+--TEST--
+bug #34794: proc_close() hangs when used with two processes
+--SKIPIF--
+<?php
+if (!is_executable('/bin/cat')) echo 'skip cat not found';
+?>
+--FILE--
+<?php
+echo "Opening process 1\n";
+$process1 = proc_open('/bin/cat', array(0 => array('pipe', 'r'), 1 
=>array('pipe', 'r')), $pipes1);
+
+echo "Opening process 2\n";
+$process2 = proc_open('/bin/cat', array(0 => array('pipe', 'r'), 1 
=>array('pipe', 'r')), $pipes2);
+
+
+echo "Closing process 1\n";
+fclose($pipes1[0]);
+fclose($pipes1[1]);
+proc_close($process1);
+
+echo "Closing process 2\n";
+fclose($pipes2[0]);
+fclose($pipes2[1]);
+proc_close($process2);
+
+echo "Done\n";
+
+?>
+--EXPECTF--
+Opening process 1
+Opening process 2
+Closing process 1
+Closing process 2
+Done

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to