[PHP-CVS] cvs: php-src /ext/standard proc_open.c /ext/standard/tests/file bug41874.phpt bug41874_1.phpt bug41874_2.phpt bug41874_3.phpt
pajoye Tue Jun 9 14:07:06 2009 UTC Modified files: /php-src/ext/standard proc_open.c /php-src/ext/standard/tests/filebug41874.phpt bug41874_1.phpt bug41874_2.phpt bug41874_3.phpt Log: - MFB: #41874, separate STDOUT and STDERR in exec functions http://cvs.php.net/viewvc.cgi/php-src/ext/standard/proc_open.c?r1=1.68r2=1.69diff_format=u Index: php-src/ext/standard/proc_open.c diff -u php-src/ext/standard/proc_open.c:1.68 php-src/ext/standard/proc_open.c:1.69 --- php-src/ext/standard/proc_open.c:1.68 Thu Mar 26 20:02:29 2009 +++ php-src/ext/standard/proc_open.cTue Jun 9 14:07:06 2009 @@ -15,7 +15,7 @@ | Author: Wez Furlong w...@thebrainroom.com | +--+ */ -/* $Id: proc_open.c,v 1.68 2009/03/26 20:02:29 felipe Exp $ */ +/* $Id: proc_open.c,v 1.69 2009/06/09 14:07:06 pajoye Exp $ */ #if 0 (defined(__linux__) || defined(sun) || defined(__IRIX__)) # define _BSD_SOURCE /* linux wants this when XOPEN mode is on */ @@ -444,6 +444,7 @@ STARTUPINFO si; BOOL newprocok; SECURITY_ATTRIBUTES security; + DWORD dwCreateFlags = 0; char *command_with_cmd; UINT old_error_mode; #endif @@ -742,13 +743,18 @@ old_error_mode = SetErrorMode(SEM_FAILCRITICALERRORS|SEM_NOGPFAULTERRORBOX); } + dwCreateFlags = NORMAL_PRIORITY_CLASS; + if(strcmp(sapi_module.name, cli) != 0) { + dwCreateFlags |= CREATE_NO_WINDOW; + } + if (bypass_shell) { - newprocok = CreateProcess(NULL, command, security, security, TRUE, NORMAL_PRIORITY_CLASS|CREATE_NO_WINDOW, env.envp, cwd, si, pi); + newprocok = CreateProcess(NULL, command, security, security, TRUE, dwCreateFlags, env.envp, cwd, si, pi); } else { spprintf(command_with_cmd, 0, %s /c %s, GetVersion() 0x8000 ? COMSPEC_NT : COMSPEC_9X, command); - newprocok = CreateProcess(NULL, command_with_cmd, security, security, TRUE, NORMAL_PRIORITY_CLASS|CREATE_NO_WINDOW, env.envp, cwd, si, pi); - + newprocok = CreateProcess(NULL, command_with_cmd, security, security, TRUE, dwCreateFlags, env.envp, cwd, si, pi); + efree(command_with_cmd); } http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/bug41874.phpt?r1=1.1r2=1.2diff_format=u Index: php-src/ext/standard/tests/file/bug41874.phpt diff -u /dev/null php-src/ext/standard/tests/file/bug41874.phpt:1.2 --- /dev/null Tue Jun 9 14:07:06 2009 +++ php-src/ext/standard/tests/file/bug41874.phpt Tue Jun 9 14:07:06 2009 @@ -0,0 +1,22 @@ +--TEST-- +bug #41874 (Separate STDOUT and STDERR in exec functions) +--CREDITS-- +Venkat Raman Don +--SKIPIF-- +?php +if(substr(PHP_OS, 0, 3) != 'WIN' ) { + die('skip windows only test'); +} +? +--FILE-- +?php +$result = exec('cd 1:\\non_existant; dir nonexistant'); +echo $result; +system('cd 1:\\non_existant; dir nonexistant'); +$result = shell_exec('cd 1:\\non_existant; dir nonexistant'); +echo $result; +? +--EXPECT-- +The system cannot find the drive specified. +The system cannot find the drive specified. +The system cannot find the drive specified. http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/bug41874_1.phpt?r1=1.1r2=1.2diff_format=u Index: php-src/ext/standard/tests/file/bug41874_1.phpt diff -u /dev/null php-src/ext/standard/tests/file/bug41874_1.phpt:1.2 --- /dev/null Tue Jun 9 14:07:06 2009 +++ php-src/ext/standard/tests/file/bug41874_1.phpt Tue Jun 9 14:07:06 2009 @@ -0,0 +1,16 @@ +--TEST-- +bug #41874 (Separate STDOUT and STDERR in exec functions) +--CREDITS-- +Venkat Raman Don +--SKIPIF-- +?php +if(substr(PHP_OS, 0, 3) != 'WIN' ) { + die('skip windows only test'); +} +? +--FILE-- +?php +popen(1:\\non_existent, r); +? +--EXPECT-- +The system cannot find the drive specified. \ No newline at end of file http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/bug41874_2.phpt?r1=1.1r2=1.2diff_format=u Index: php-src/ext/standard/tests/file/bug41874_2.phpt diff -u /dev/null php-src/ext/standard/tests/file/bug41874_2.phpt:1.2 --- /dev/null Tue Jun 9 14:07:06 2009 +++ php-src/ext/standard/tests/file/bug41874_2.phpt Tue Jun 9 14:07:06 2009 @@ -0,0 +1,17 @@ +--TEST-- +bug #41874 (Separate STDOUT and STDERR in exec functions) +--CREDITS-- +Venkat Raman Don +--SKIPIF-- +?php +if(substr(PHP_OS, 0, 3) != 'WIN' ) { + die('skip windows only test'); +} +? +--FILE-- +?php +$result = exec('cd 1:\\non_existant; dir nonexistant'); +echo $result; +? +--EXPECT-- +The system cannot find the drive specified. \ No newline at end of file http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/bug41874_3.phpt?r1=1.1r2=1.2diff_format=u Index: php-src/ext/standard/tests/file/bug41874_3.phpt diff
[PHP-CVS] cvs: php-src /ext/standard proc_open.c
dmitry Thu Aug 21 11:28:09 2008 UTC Modified files: /php-src/ext/standard proc_open.c Log: Adder error code into error message http://cvs.php.net/viewvc.cgi/php-src/ext/standard/proc_open.c?r1=1.63r2=1.64diff_format=u Index: php-src/ext/standard/proc_open.c diff -u php-src/ext/standard/proc_open.c:1.63 php-src/ext/standard/proc_open.c:1.64 --- php-src/ext/standard/proc_open.c:1.63 Wed Jul 23 11:24:35 2008 +++ php-src/ext/standard/proc_open.cThu Aug 21 11:28:09 2008 @@ -15,7 +15,7 @@ | Author: Wez Furlong [EMAIL PROTECTED] | +--+ */ -/* $Id: proc_open.c,v 1.63 2008/07/23 11:24:35 tony2001 Exp $ */ +/* $Id: proc_open.c,v 1.64 2008/08/21 11:28:09 dmitry Exp $ */ #if 0 (defined(__linux__) || defined(sun) || defined(__IRIX__)) # define _BSD_SOURCE /* linux wants this when XOPEN mode is on */ @@ -762,6 +762,8 @@ } if (FALSE == newprocok) { + DWORD dw = GetLastError(); + /* clean up all the descriptors */ for (i = 0; i ndesc; i++) { CloseHandle(descriptors[i].childend); @@ -769,7 +771,7 @@ CloseHandle(descriptors[i].parentend); } } - php_error_docref(NULL TSRMLS_CC, E_WARNING, CreateProcess failed); + php_error_docref(NULL TSRMLS_CC, E_WARNING, CreateProcess failed, error code - %u, dw); goto exit_fail; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard proc_open.c /ext/standard/tests/general_functions bug44667.phpt
janiTue Apr 8 08:42:05 2008 UTC Added files: /php-src/ext/standard/tests/general_functions bug44667.phpt Modified files: /php-src/ext/standard proc_open.c Log: - Fixed bug #44667 (proc_open does not handle pipes with the mode wb correctly) http://cvs.php.net/viewvc.cgi/php-src/ext/standard/proc_open.c?r1=1.60r2=1.61diff_format=u Index: php-src/ext/standard/proc_open.c diff -u php-src/ext/standard/proc_open.c:1.60 php-src/ext/standard/proc_open.c:1.61 --- php-src/ext/standard/proc_open.c:1.60 Mon Dec 31 07:12:16 2007 +++ php-src/ext/standard/proc_open.cTue Apr 8 08:42:05 2008 @@ -15,7 +15,7 @@ | Author: Wez Furlong [EMAIL PROTECTED] | +--+ */ -/* $Id: proc_open.c,v 1.60 2007/12/31 07:12:16 sebastian Exp $ */ +/* $Id: proc_open.c,v 1.61 2008/04/08 08:42:05 jani Exp $ */ #if 0 (defined(__linux__) || defined(sun) || defined(__IRIX__)) # define _BSD_SOURCE /* linux wants this when XOPEN mode is on */ @@ -600,7 +600,7 @@ goto exit_fail; } - if (strcmp(Z_STRVAL_PP(zmode), w) != 0) { + if (strncmp(Z_STRVAL_PP(zmode), w, 1) != 0) { descriptors[ndesc].parentend = newpipe[1]; descriptors[ndesc].childend = newpipe[0]; descriptors[ndesc].mode |= DESC_PARENT_MODE_WRITE; http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/general_functions/bug44667.phpt?view=markuprev=1.1 Index: php-src/ext/standard/tests/general_functions/bug44667.phpt +++ php-src/ext/standard/tests/general_functions/bug44667.phpt --TEST-- Bug #44667 (proc_open() does not handle pipes with the mode 'wb' correctly) --SKIPIF-- ?php if (!is_executable('/bin/cat')) echo 'skip cat not found'; ? --FILE-- ?php $pipes = array(); $descriptor_spec = array( 0 = array('pipe', 'rb'), 1 = array('pipe', 'wb'), ); $proc = proc_open('cat', $descriptor_spec, $pipes); fwrite($pipes[0], 'Hello', 5); fflush($pipes[0]); fclose($pipes[0]); $result = fread($pipes[1], 5); fclose($pipes[1]); proc_close($proc); echo Result is: , $result, \n; echo Done\n; ? --EXPECTF-- Result is: Hello Done -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard proc_open.c
nlopess Wed Sep 12 11:46:08 2007 UTC Modified files: /php-src/ext/standard proc_open.c Log: MFB: fix #39651 http://cvs.php.net/viewvc.cgi/php-src/ext/standard/proc_open.c?r1=1.58r2=1.59diff_format=u Index: php-src/ext/standard/proc_open.c diff -u php-src/ext/standard/proc_open.c:1.58 php-src/ext/standard/proc_open.c:1.59 --- php-src/ext/standard/proc_open.c:1.58 Fri Aug 17 10:42:12 2007 +++ php-src/ext/standard/proc_open.cWed Sep 12 11:46:08 2007 @@ -15,7 +15,7 @@ | Author: Wez Furlong [EMAIL PROTECTED] | +--+ */ -/* $Id: proc_open.c,v 1.58 2007/08/17 10:42:12 jani Exp $ */ +/* $Id: proc_open.c,v 1.59 2007/09/12 11:46:08 nlopess Exp $ */ #if 0 (defined(__linux__) || defined(sun) || defined(__IRIX__)) # define _BSD_SOURCE /* linux wants this when XOPEN mode is on */ @@ -669,6 +669,12 @@ #ifdef PHP_WIN32 descriptors[ndesc].childend = dup_fd_as_handle(fd); _close(fd); + + /* simulate the append mode by fseeking to the end of the file + this introduces a potential race-condition, but it is the best we can do, though */ + if (strchr(Z_STRVAL_PP(zmode), 'a')) { + SetFilePointer(descriptors[ndesc].childend, 0, NULL, FILE_END); + } #else descriptors[ndesc].childend = fd; #endif -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard proc_open.c
janiFri Aug 17 10:42:13 2007 UTC Modified files: /php-src/ext/standard proc_open.c Log: - Fixed bug #41904 (proc_open with empty env array) http://cvs.php.net/viewvc.cgi/php-src/ext/standard/proc_open.c?r1=1.57r2=1.58diff_format=u Index: php-src/ext/standard/proc_open.c diff -u php-src/ext/standard/proc_open.c:1.57 php-src/ext/standard/proc_open.c:1.58 --- php-src/ext/standard/proc_open.c:1.57 Mon May 28 23:00:25 2007 +++ php-src/ext/standard/proc_open.cFri Aug 17 10:42:12 2007 @@ -15,7 +15,7 @@ | Author: Wez Furlong [EMAIL PROTECTED] | +--+ */ -/* $Id: proc_open.c,v 1.57 2007/05/28 23:00:25 iliaa Exp $ */ +/* $Id: proc_open.c,v 1.58 2007/08/17 10:42:12 jani Exp $ */ #if 0 (defined(__linux__) || defined(sun) || defined(__IRIX__)) # define _BSD_SOURCE /* linux wants this when XOPEN mode is on */ @@ -95,6 +95,10 @@ cnt = zend_hash_num_elements(Z_ARRVAL_P(environment)); if (cnt 1) { +#ifndef PHP_WIN32 + env.envarray = (char **) pecalloc(1, sizeof(char *), is_persistent); +#endif + env.envp = (char *) pecalloc(4, 1, is_persistent); return env; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard proc_open.c
stasMon Apr 2 20:48:30 2007 UTC Modified files: /php-src/ext/standard proc_open.c Log: fix for #33664 Console window appears when using exec() http://cvs.php.net/viewvc.cgi/php-src/ext/standard/proc_open.c?r1=1.54r2=1.55diff_format=u Index: php-src/ext/standard/proc_open.c diff -u php-src/ext/standard/proc_open.c:1.54 php-src/ext/standard/proc_open.c:1.55 --- php-src/ext/standard/proc_open.c:1.54 Sat Feb 24 16:25:55 2007 +++ php-src/ext/standard/proc_open.cMon Apr 2 20:48:30 2007 @@ -15,7 +15,7 @@ | Author: Wez Furlong [EMAIL PROTECTED] | +--+ */ -/* $Id: proc_open.c,v 1.54 2007/02/24 16:25:55 helly Exp $ */ +/* $Id: proc_open.c,v 1.55 2007/04/02 20:48:30 stas Exp $ */ #if 0 (defined(__linux__) || defined(sun) || defined(__IRIX__)) # define _BSD_SOURCE /* linux wants this when XOPEN mode is on */ @@ -738,11 +738,11 @@ } if (bypass_shell) { - newprocok = CreateProcess(NULL, command, security, security, TRUE, NORMAL_PRIORITY_CLASS, env.envp, cwd, si, pi); + newprocok = CreateProcess(NULL, command, security, security, TRUE, NORMAL_PRIORITY_CLASS|CREATE_NO_WINDOW, env.envp, cwd, si, pi); } else { spprintf(command_with_cmd, 0, %s /c %s, GetVersion() 0x8000 ? COMSPEC_NT : COMSPEC_9X, command); - newprocok = CreateProcess(NULL, command_with_cmd, security, security, TRUE, NORMAL_PRIORITY_CLASS, env.envp, cwd, si, pi); + newprocok = CreateProcess(NULL, command_with_cmd, security, security, TRUE, NORMAL_PRIORITY_CLASS|CREATE_NO_WINDOW, env.envp, cwd, si, pi); efree(command_with_cmd); } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard proc_open.c /ext/standard/tests/general_functions bug39322.phpt phpcredits.phpt proc_open02.phpt
nlopess Wed Feb 14 19:20:15 2007 UTC Modified files: /php-src/ext/standard proc_open.c /php-src/ext/standard/tests/general_functions bug39322.phpt proc_open02.phpt phpcredits.phpt Log: MFB http://cvs.php.net/viewvc.cgi/php-src/ext/standard/proc_open.c?r1=1.52r2=1.53diff_format=u Index: php-src/ext/standard/proc_open.c diff -u php-src/ext/standard/proc_open.c:1.52 php-src/ext/standard/proc_open.c:1.53 --- php-src/ext/standard/proc_open.c:1.52 Tue Feb 13 19:56:42 2007 +++ php-src/ext/standard/proc_open.cWed Feb 14 19:20:14 2007 @@ -15,7 +15,7 @@ | Author: Wez Furlong [EMAIL PROTECTED] | +--+ */ -/* $Id: proc_open.c,v 1.52 2007/02/13 19:56:42 nlopess Exp $ */ +/* $Id: proc_open.c,v 1.53 2007/02/14 19:20:14 nlopess Exp $ */ #if 0 (defined(__linux__) || defined(sun) || defined(__IRIX__)) # define _BSD_SOURCE /* linux wants this when XOPEN mode is on */ @@ -253,7 +253,7 @@ } /* }}} */ -/* {{{ proto int proc_terminate(resource process [, long signal]) U +/* {{{ proto bool proc_terminate(resource process [, long signal]) U kill a process opened by proc_open */ PHP_FUNCTION(proc_terminate) { @@ -268,13 +268,18 @@ ZEND_FETCH_RESOURCE(proc, struct php_process_handle *, zproc, -1, process, le_proc_open); #ifdef PHP_WIN32 - TerminateProcess(proc-childHandle, 255); + if (TerminateProcess(proc-childHandle, 255)) { + RETURN_TRUE; + } else { + RETURN_FALSE; + } #else - kill(proc-child, sig_no); + if (kill(proc-child, sig_no) == 0) { + RETURN_TRUE; + } else { + RETURN_FALSE; + } #endif - - zend_list_delete(Z_LVAL_P(zproc)); - RETURN_LONG(FG(pclose_ret)); } /* }}} */ http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/general_functions/bug39322.phpt?r1=1.1r2=1.2diff_format=u Index: php-src/ext/standard/tests/general_functions/bug39322.phpt diff -u /dev/null php-src/ext/standard/tests/general_functions/bug39322.phpt:1.2 --- /dev/null Wed Feb 14 19:20:15 2007 +++ php-src/ext/standard/tests/general_functions/bug39322.phpt Wed Feb 14 19:20:15 2007 @@ -0,0 +1,44 @@ +--TEST-- +bug #39322: proc_terminate() loosing process resource +--SKIPIF-- +?php +if (!is_executable('/bin/sleep')) echo 'skip sleep not found'; +? +--FILE-- +?php +$descriptors = array( +0 = array('pipe', 'r'), +1 = array('pipe', 'w'), +2 = array('pipe', 'w')); + +$pipes = array(); + +$process = proc_open('/bin/sleep 120', $descriptors, $pipes); + +proc_terminate($process); +sleep(1); // wait a bit to let the process finish +var_dump(proc_get_status($process)); + +echo Done!\n; + +? +--EXPECTF-- +array(8) { + [command]= + string(14) /bin/sleep 120 + [pid]= + int(%d) + [running]= + bool(false) + [signaled]= + bool(true) + [stopped]= + bool(false) + [exitcode]= + int(-1) + [termsig]= + int(15) + [stopsig]= + int(0) +} +Done! http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/general_functions/proc_open02.phpt?r1=1.1r2=1.2diff_format=u Index: php-src/ext/standard/tests/general_functions/proc_open02.phpt diff -u /dev/null php-src/ext/standard/tests/general_functions/proc_open02.phpt:1.2 --- /dev/null Wed Feb 14 19:20:15 2007 +++ php-src/ext/standard/tests/general_functions/proc_open02.phpt Wed Feb 14 19:20:15 2007 @@ -0,0 +1,70 @@ +--TEST-- +proc_open +--SKIPIF-- +?php +if (!is_executable('/bin/sleep')) echo 'skip no sleep'; +if (!is_executable('/bin/nohup')) echo 'skip no nohup'; +? +--FILE-- +?php +$ds = array(array('pipe', 'r')); + +$cat = proc_open( + '/bin/nohup /bin/sleep 50', + $ds, + $pipes +); + +var_dump(proc_terminate($cat, 1)); // send a SIGHUP +sleep(1); +var_dump(proc_get_status($cat)); + +var_dump(proc_terminate($cat)); // now really quit it +sleep(1); +var_dump(proc_get_status($cat)); + +proc_close($cat); + +echo Done!\n; + +? +--EXPECTF-- +bool(true) +array(8) { + [command]= + string(24) /bin/nohup /bin/sleep 50 + [pid]= + int(%d) + [running]= + bool(true) + [signaled]= + bool(false) + [stopped]= + bool(false) + [exitcode]= + int(-1) + [termsig]= + int(0) + [stopsig]= + int(0) +} +bool(true) +array(8) { + [command]= + string(24) /bin/nohup /bin/sleep 50 + [pid]= + int(%d) + [running]= + bool(false) + [signaled]= + bool(true) + [stopped]= + bool(false) + [exitcode]= + int(-1) + [termsig]= + int(15) + [stopsig]= + int(0) +} +Done! http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/general_functions/phpcredits.phpt?r1=1.2r2=1.3diff_format=u Index: php-src/ext/standard/tests/general_functions/phpcredits.phpt diff -u php-src/ext/standard/tests/general_functions/phpcredits.phpt:1.2
[PHP-CVS] cvs: php-src /ext/standard proc_open.c
dmitry Tue Jan 9 16:27:32 2007 UTC Modified files: /php-src/ext/standard proc_open.c Log: Close open files in case of failure (Amit) http://cvs.php.net/viewvc.cgi/php-src/ext/standard/proc_open.c?r1=1.50r2=1.51diff_format=u Index: php-src/ext/standard/proc_open.c diff -u php-src/ext/standard/proc_open.c:1.50 php-src/ext/standard/proc_open.c:1.51 --- php-src/ext/standard/proc_open.c:1.50 Sat Jan 6 09:08:06 2007 +++ php-src/ext/standard/proc_open.cTue Jan 9 16:27:32 2007 @@ -15,7 +15,7 @@ | Author: Wez Furlong [EMAIL PROTECTED] | +--+ */ -/* $Id: proc_open.c,v 1.50 2007/01/06 09:08:06 dmitry Exp $ */ +/* $Id: proc_open.c,v 1.51 2007/01/09 16:27:32 dmitry Exp $ */ #if 0 (defined(__linux__) || defined(sun) || defined(__IRIX__)) # define _BSD_SOURCE /* linux wants this when XOPEN mode is on */ @@ -748,6 +748,13 @@ } if (FALSE == newprocok) { + /* clean up all the descriptors */ + for (i = 0; i ndesc; i++) { + CloseHandle(descriptors[i].childend); + if (descriptors[i].parentend) { + CloseHandle(descriptors[i].parentend); + } + } php_error_docref(NULL TSRMLS_CC, E_WARNING, CreateProcess failed); goto exit_fail; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard proc_open.c
dmitry Sat Jan 6 09:08:07 2007 UTC Modified files: /php-src/ext/standard proc_open.c Log: Improved proc_open(). Now on Windows it can run external commands not through CMD.EXE http://cvs.php.net/viewvc.cgi/php-src/ext/standard/proc_open.c?r1=1.49r2=1.50diff_format=u Index: php-src/ext/standard/proc_open.c diff -u php-src/ext/standard/proc_open.c:1.49 php-src/ext/standard/proc_open.c:1.50 --- php-src/ext/standard/proc_open.c:1.49 Tue Jan 2 15:31:58 2007 +++ php-src/ext/standard/proc_open.cSat Jan 6 09:08:06 2007 @@ -15,7 +15,7 @@ | Author: Wez Furlong [EMAIL PROTECTED] | +--+ */ -/* $Id: proc_open.c,v 1.49 2007/01/02 15:31:58 nlopess Exp $ */ +/* $Id: proc_open.c,v 1.50 2007/01/06 09:08:06 dmitry Exp $ */ #if 0 (defined(__linux__) || defined(sun) || defined(__IRIX__)) # define _BSD_SOURCE /* linux wants this when XOPEN mode is on */ @@ -455,6 +455,7 @@ int is_persistent = 0; /* TODO: ensure that persistent procs will work */ #ifdef PHP_WIN32 int suppress_errors = 0; + int bypass_shell = 0; #endif #if PHP_CAN_DO_PTS php_file_descriptor_t dev_ptmx = -1;/* master */ @@ -476,10 +477,17 @@ zval **item; #ifdef PHP_WIN32 if (SUCCESS == zend_ascii_hash_find(Z_ARRVAL_P(other_options), suppress_errors, sizeof(suppress_errors), (void**)item)) { - if (Z_TYPE_PP(item) == IS_BOOL Z_BVAL_PP(item)) { + if ((Z_TYPE_PP(item) == IS_BOOL || Z_TYPE_PP(item) == IS_LONG) + Z_LVAL_PP(item)) { suppress_errors = 1; } } + if (SUCCESS == zend_ascii_hash_find(Z_ARRVAL_P(other_options), bypass_shell, sizeof(bypass_shell), (void**)item)) { + if ((Z_TYPE_PP(item) == IS_BOOL || Z_TYPE_PP(item) == IS_LONG) + Z_LVAL_PP(item)) { + bypass_shell = 1; + } + } #endif /* Suppresses automatic application of unicode filters when unicode.semantics=on */ if (SUCCESS == zend_ascii_hash_find(Z_ARRVAL_P(other_options), binary_pipes, sizeof(binary_pipes), (void**)item)) { @@ -720,21 +728,25 @@ memset(pi, 0, sizeof(pi)); - command_with_cmd = emalloc(command_len + sizeof(COMSPEC_9X) + 1 + sizeof( /c )); - sprintf(command_with_cmd, %s /c %s, GetVersion() 0x8000 ? COMSPEC_NT : COMSPEC_9X, command); - if (suppress_errors) { old_error_mode = SetErrorMode(SEM_FAILCRITICALERRORS|SEM_NOGPFAULTERRORBOX); } - newprocok = CreateProcess(NULL, command_with_cmd, security, security, TRUE, NORMAL_PRIORITY_CLASS, env.envp, cwd, si, pi); + if (bypass_shell) { + newprocok = CreateProcess(NULL, command, security, security, TRUE, NORMAL_PRIORITY_CLASS, env.envp, cwd, si, pi); + } else { + command_with_cmd = emalloc(command_len + sizeof(COMSPEC_9X) + 1 + sizeof( /c )); + sprintf(command_with_cmd, %s /c %s, GetVersion() 0x8000 ? COMSPEC_NT : COMSPEC_9X, command); + + newprocok = CreateProcess(NULL, command_with_cmd, security, security, TRUE, NORMAL_PRIORITY_CLASS, env.envp, cwd, si, pi); + + efree(command_with_cmd); + } if (suppress_errors) { SetErrorMode(old_error_mode); } - efree(command_with_cmd); - if (FALSE == newprocok) { php_error_docref(NULL TSRMLS_CC, E_WARNING, CreateProcess failed); goto exit_fail; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard proc_open.c
nlopess Tue Jan 2 15:31:58 2007 UTC Modified files: /php-src/ext/standard proc_open.c Log: MFB http://cvs.php.net/viewvc.cgi/php-src/ext/standard/proc_open.c?r1=1.48r2=1.49diff_format=u Index: php-src/ext/standard/proc_open.c diff -u php-src/ext/standard/proc_open.c:1.48 php-src/ext/standard/proc_open.c:1.49 --- php-src/ext/standard/proc_open.c:1.48 Mon Jan 1 09:29:32 2007 +++ php-src/ext/standard/proc_open.cTue Jan 2 15:31:58 2007 @@ -15,7 +15,7 @@ | Author: Wez Furlong [EMAIL PROTECTED] | +--+ */ -/* $Id: proc_open.c,v 1.48 2007/01/01 09:29:32 sebastian Exp $ */ +/* $Id: proc_open.c,v 1.49 2007/01/02 15:31:58 nlopess Exp $ */ #if 0 (defined(__linux__) || defined(sun) || defined(__IRIX__)) # define _BSD_SOURCE /* linux wants this when XOPEN mode is on */ @@ -602,8 +602,6 @@ } #endif - - } else if (strcmp(Z_STRVAL_PP(ztype), file) == 0) { zval **zfile, **zmode; char *filename; @@ -781,7 +779,8 @@ /* clean up all the descriptors */ for (i = 0; i ndesc; i++) { close(descriptors[i].childend); - close(descriptors[i].parentend); + if (descriptors[i].parentend) + close(descriptors[i].parentend); } php_error_docref(NULL TSRMLS_CC, E_WARNING, procve failed - %s, strerror(errno)); goto exit_fail; @@ -850,7 +849,8 @@ /* clean up all the descriptors */ for (i = 0; i ndesc; i++) { close(descriptors[i].childend); - close(descriptors[i].parentend); + if (descriptors[i].parentend) + close(descriptors[i].parentend); } php_error_docref(NULL TSRMLS_CC, E_WARNING, fork failed - %s, strerror(errno)); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard proc_open.c proc_open.h
nlopess Sun Dec 31 14:49:06 2006 UTC Modified files: /php-src/ext/standard proc_open.c proc_open.h Log: MFB: fix PID info on windows http://cvs.php.net/viewvc.cgi/php-src/ext/standard/proc_open.c?r1=1.45r2=1.46diff_format=u Index: php-src/ext/standard/proc_open.c diff -u php-src/ext/standard/proc_open.c:1.45 php-src/ext/standard/proc_open.c:1.46 --- php-src/ext/standard/proc_open.c:1.45 Tue Oct 3 19:37:01 2006 +++ php-src/ext/standard/proc_open.cSun Dec 31 14:49:06 2006 @@ -15,7 +15,7 @@ | Author: Wez Furlong [EMAIL PROTECTED] | +--+ */ -/* $Id: proc_open.c,v 1.45 2006/10/03 19:37:01 pollita Exp $ */ +/* $Id: proc_open.c,v 1.46 2006/12/31 14:49:06 nlopess Exp $ */ #if 0 (defined(__linux__) || defined(sun) || defined(__IRIX__)) # define _BSD_SOURCE /* linux wants this when XOPEN mode is on */ @@ -216,10 +216,10 @@ #ifdef PHP_WIN32 - WaitForSingleObject(proc-child, INFINITE); - GetExitCodeProcess(proc-child, wstatus); + WaitForSingleObject(proc-childHandle, INFINITE); + GetExitCodeProcess(proc-childHandle, wstatus); FG(pclose_ret) = wstatus; - CloseHandle(proc-child); + CloseHandle(proc-childHandle); #elif HAVE_SYS_WAIT_H @@ -268,7 +268,7 @@ ZEND_FETCH_RESOURCE(proc, struct php_process_handle *, zproc, -1, process, le_proc_open); #ifdef PHP_WIN32 - TerminateProcess(proc-child, 255); + TerminateProcess(proc-childHandle, 255); #else kill(proc-child, sig_no); #endif @@ -336,7 +336,7 @@ #ifdef PHP_WIN32 - GetExitCodeProcess(proc-child, wstatus); + GetExitCodeProcess(proc-childHandle, wstatus); running = wstatus == STILL_ACTIVE; exitcode == STILL_ACTIVE ? -1 : wstatus; @@ -436,6 +436,7 @@ struct php_proc_open_descriptor_item descriptors[PHP_PROC_OPEN_MAX_DESCRIPTORS]; #ifdef PHP_WIN32 PROCESS_INFORMATION pi; + HANDLE childHandle; STARTUPINFO si; BOOL newprocok; SECURITY_ATTRIBUTES security; @@ -740,7 +741,8 @@ goto exit_fail; } - child = pi.hProcess; + childHandle = pi.hProcess; + child = pi.dwProcessId; CloseHandle(pi.hThread); #elif defined(NETWARE) @@ -865,6 +867,9 @@ proc-command = pestrdup(command, is_persistent); proc-npipes = ndesc; proc-child = child; +#ifdef PHP_WIN32 + proc-childHandle = childHandle; +#endif proc-env = env; if (pipes != NULL) { http://cvs.php.net/viewvc.cgi/php-src/ext/standard/proc_open.h?r1=1.6r2=1.7diff_format=u Index: php-src/ext/standard/proc_open.h diff -u php-src/ext/standard/proc_open.h:1.6 php-src/ext/standard/proc_open.h:1.7 --- php-src/ext/standard/proc_open.h:1.6Sun Jan 1 13:09:55 2006 +++ php-src/ext/standard/proc_open.hSun Dec 31 14:49:06 2006 @@ -15,11 +15,11 @@ | Author: Wez Furlong [EMAIL PROTECTED] | +--+ */ -/* $Id: proc_open.h,v 1.6 2006/01/01 13:09:55 sniper Exp $ */ +/* $Id: proc_open.h,v 1.7 2006/12/31 14:49:06 nlopess Exp $ */ #ifdef PHP_WIN32 typedef HANDLE php_file_descriptor_t; -typedef HANDLE php_process_id_t; +typedef DWORD php_process_id_t; #else typedef int php_file_descriptor_t; typedef pid_t php_process_id_t; @@ -40,6 +40,9 @@ struct php_process_handle { php_process_id_tchild; +#ifdef PHP_WIN32 + HANDLE childHandle; +#endif int npipes; long pipes[PHP_PROC_OPEN_MAX_DESCRIPTORS]; char *command; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard proc_open.c
nlopess Sun Dec 31 15:28:56 2006 UTC Modified files: /php-src/ext/standard proc_open.c Log: MFB: fix #36427. patch by jdolecek at NetBSD dot org http://cvs.php.net/viewvc.cgi/php-src/ext/standard/proc_open.c?r1=1.46r2=1.47diff_format=u Index: php-src/ext/standard/proc_open.c diff -u php-src/ext/standard/proc_open.c:1.46 php-src/ext/standard/proc_open.c:1.47 --- php-src/ext/standard/proc_open.c:1.46 Sun Dec 31 14:49:06 2006 +++ php-src/ext/standard/proc_open.cSun Dec 31 15:28:56 2006 @@ -15,7 +15,7 @@ | Author: Wez Furlong [EMAIL PROTECTED] | +--+ */ -/* $Id: proc_open.c,v 1.46 2006/12/31 14:49:06 nlopess Exp $ */ +/* $Id: proc_open.c,v 1.47 2006/12/31 15:28:56 nlopess Exp $ */ #if 0 (defined(__linux__) || defined(sun) || defined(__IRIX__)) # define _BSD_SOURCE /* linux wants this when XOPEN mode is on */ @@ -652,7 +652,8 @@ } #ifdef PHP_WIN32 - descriptors[ndesc].childend = (HANDLE)_get_osfhandle(fd); + descriptors[ndesc].childend = dup_fd_as_handle(fd); + _close(fd); #else descriptors[ndesc].childend = fd; #endif -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard proc_open.c
pollita Mon Oct 2 21:02:08 2006 UTC Modified files: /php-src/ext/standard proc_open.c Log: Flag the easy stuff out of the way, proc_open() is the real beast in here http://cvs.php.net/viewvc.cgi/php-src/ext/standard/proc_open.c?r1=1.43r2=1.44diff_format=u Index: php-src/ext/standard/proc_open.c diff -u php-src/ext/standard/proc_open.c:1.43 php-src/ext/standard/proc_open.c:1.44 --- php-src/ext/standard/proc_open.c:1.43 Tue Sep 19 10:38:31 2006 +++ php-src/ext/standard/proc_open.cMon Oct 2 21:02:08 2006 @@ -15,7 +15,7 @@ | Author: Wez Furlong [EMAIL PROTECTED] | +--+ */ -/* $Id: proc_open.c,v 1.43 2006/09/19 10:38:31 dmitry Exp $ */ +/* $Id: proc_open.c,v 1.44 2006/10/02 21:02:08 pollita Exp $ */ #if 0 (defined(__linux__) || defined(sun) || defined(__IRIX__)) # define _BSD_SOURCE /* linux wants this when XOPEN mode is on */ @@ -253,7 +253,7 @@ } /* }}} */ -/* {{{ proto int proc_terminate(resource process [, long signal]) +/* {{{ proto int proc_terminate(resource process [, long signal]) U kill a process opened by proc_open */ PHP_FUNCTION(proc_terminate) { @@ -278,7 +278,7 @@ } /* }}} */ -/* {{{ proto int proc_close(resource process) +/* {{{ proto int proc_close(resource process) U close a process opened by proc_open */ PHP_FUNCTION(proc_close) { @@ -296,7 +296,7 @@ } /* }}} */ -/* {{{ proto array proc_get_status(resource process) +/* {{{ proto array proc_get_status(resource process) U get information about a process opened by proc_open */ PHP_FUNCTION(proc_get_status) { @@ -319,7 +319,19 @@ array_init(return_value); - add_ascii_assoc_string(return_value, command, proc-command, 1); + if (UG(unicode)) { + UChar *ucmd; + int ucmd_len; + + if (SUCCESS == php_stream_path_decode(php_plain_files_wrapper, ucmd, ucmd_len, proc-command, strlen(proc-command), REPORT_ERRORS, FG(default_context))) { + add_ascii_assoc_unicodel(return_value, command, ucmd, ucmd_len, 0); + } else { + /* Fallback on original binary string */ + add_ascii_assoc_string(return_value, command, proc-command, 1); + } + } else { + add_ascii_assoc_string(return_value, command, proc-command, 1); + } add_ascii_assoc_long(return_value, pid, (long) proc-child); #ifdef PHP_WIN32 -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard proc_open.c
tony2001Thu Jun 1 14:03:38 2006 UTC Modified files: /php-src/ext/standard proc_open.c Log: suppress_errors is used only on Win32, no need to look for it on other systems http://cvs.php.net/viewcvs.cgi/php-src/ext/standard/proc_open.c?r1=1.41r2=1.42diff_format=u Index: php-src/ext/standard/proc_open.c diff -u php-src/ext/standard/proc_open.c:1.41 php-src/ext/standard/proc_open.c:1.42 --- php-src/ext/standard/proc_open.c:1.41 Tue Feb 21 20:12:42 2006 +++ php-src/ext/standard/proc_open.cThu Jun 1 14:03:38 2006 @@ -15,7 +15,7 @@ | Author: Wez Furlong [EMAIL PROTECTED] | +--+ */ -/* $Id: proc_open.c,v 1.41 2006/02/21 20:12:42 dmitry Exp $ */ +/* $Id: proc_open.c,v 1.42 2006/06/01 14:03:38 tony2001 Exp $ */ #if 0 (defined(__linux__) || defined(sun) || defined(__IRIX__)) # define _BSD_SOURCE /* linux wants this when XOPEN mode is on */ @@ -439,7 +439,9 @@ php_process_id_t child; struct php_process_handle *proc; int is_persistent = 0; /* TODO: ensure that persistent procs will work */ +#ifdef PHP_WIN32 int suppress_errors = 0; +#endif #if PHP_CAN_DO_PTS php_file_descriptor_t dev_ptmx = -1;/* master */ php_file_descriptor_t slave_pty = -1; @@ -451,6 +453,7 @@ RETURN_FALSE; } +#ifdef PHP_WIN32 if (other_options) { zval **item; if (SUCCESS == zend_hash_find(Z_ARRVAL_P(other_options), suppress_errors, sizeof(suppress_errors), (void**)item)) { @@ -459,6 +462,7 @@ } } } +#endif if (environment) { env = _php_array_to_envp(environment, is_persistent TSRMLS_CC); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard proc_open.c
dmitry Mon Feb 20 09:38:47 2006 UTC Modified files: /php-src/ext/standard proc_open.c Log: Fixed memory corruption http://cvs.php.net/viewcvs.cgi/php-src/ext/standard/proc_open.c?r1=1.39r2=1.40diff_format=u Index: php-src/ext/standard/proc_open.c diff -u php-src/ext/standard/proc_open.c:1.39 php-src/ext/standard/proc_open.c:1.40 --- php-src/ext/standard/proc_open.c:1.39 Sun Feb 19 18:19:33 2006 +++ php-src/ext/standard/proc_open.cMon Feb 20 09:38:47 2006 @@ -15,7 +15,7 @@ | Author: Wez Furlong [EMAIL PROTECTED] | +--+ */ -/* $Id: proc_open.c,v 1.39 2006/02/19 18:19:33 iliaa Exp $ */ +/* $Id: proc_open.c,v 1.40 2006/02/20 09:38:47 dmitry Exp $ */ #if 0 (defined(__linux__) || defined(sun) || defined(__IRIX__)) # define _BSD_SOURCE /* linux wants this when XOPEN mode is on */ @@ -809,7 +809,7 @@ proc = (struct php_process_handle*)pemalloc(sizeof(struct php_process_handle), is_persistent); proc-is_persistent = is_persistent; - proc-command = command; + proc-command = pestrdup(command, is_persistent); proc-npipes = ndesc; proc-child = child; proc-env = env; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard proc_open.c
hyanantha Fri Jul 1 02:49:30 2005 EDT Modified files: /php-src/ext/standard proc_open.c Log: As fork implementation of NetWare LibC still in experimental stages making the procve based solution ahead of HAVE_FORK. Later When fork becomes stable will revert this fix. --Kamesh from hyanantha's account http://cvs.php.net/diff.php/php-src/ext/standard/proc_open.c?r1=1.34r2=1.35ty=u Index: php-src/ext/standard/proc_open.c diff -u php-src/ext/standard/proc_open.c:1.34 php-src/ext/standard/proc_open.c:1.35 --- php-src/ext/standard/proc_open.c:1.34 Mon Jun 20 07:10:11 2005 +++ php-src/ext/standard/proc_open.cFri Jul 1 02:49:29 2005 @@ -15,7 +15,7 @@ | Author: Wez Furlong [EMAIL PROTECTED] | +--+ */ -/* $Id: proc_open.c,v 1.34 2005/06/20 11:10:11 sniper Exp $ */ +/* $Id: proc_open.c,v 1.35 2005/07/01 06:49:29 hyanantha Exp $ */ #if 0 (defined(__linux__) || defined(sun) || defined(__IRIX__)) # define _BSD_SOURCE /* linux wants this when XOPEN mode is on */ @@ -761,6 +761,46 @@ child = pi.hProcess; CloseHandle(pi.hThread); +#elif defined(NETWARE) + if (cwd) { + orig_cwd = getcwd(NULL, PATH_MAX); + chdir2(cwd); + } + channel.infd = descriptors[0].childend; + channel.outfd = descriptors[1].childend; + channel.errfd = -1; + /* Duplicate the command as processing downwards will modify it*/ + command_dup = strdup(command); + /* get a number of args */ + construct_argc_argv(command_dup, NULL, command_num_args, NULL); + child_argv = (char**) malloc((command_num_args + 1) * sizeof(char*)); + if(!child_argv) { + free(command_dup); + if (cwd orig_cwd) { + chdir2(orig_cwd); + free(orig_cwd); + } + } + /* fill the child arg vector */ + construct_argc_argv(command_dup, NULL, command_num_args, child_argv); + child_argv[command_num_args] = NULL; + child = procve(child_argv[0], PROC_DETACHED|PROC_INHERIT_CWD, NULL, channel, NULL, NULL, 0, NULL, (const char**)child_argv); + free(child_argv); + free(command_dup); + if (cwd orig_cwd) { + chdir2(orig_cwd); + free(orig_cwd); + } + if (child 0) { + /* failed to fork() */ + /* clean up all the descriptors */ + for (i = 0; i ndesc; i++) { + close(descriptors[i].childend); + close(descriptors[i].parentend); + } + php_error_docref(NULL TSRMLS_CC, E_WARNING, procve failed - %s, strerror(errno)); + goto exit_fail; + } #elif HAVE_FORK /* the unix way */ child = fork(); @@ -831,46 +871,6 @@ goto exit_fail; } -#elif defined(NETWARE) - if (cwd) { - orig_cwd = getcwd(NULL, PATH_MAX); - chdir2(cwd); - } - channel.infd = descriptors[0].childend; - channel.outfd = descriptors[1].childend; - channel.errfd = -1; - /* Duplicate the command as processing downwards will modify it*/ - command_dup = strdup(command); - /* get a number of args */ - construct_argc_argv(command_dup, NULL, command_num_args, NULL); - child_argv = (char**) malloc((command_num_args + 1) * sizeof(char*)); - if(!child_argv) { - free(command_dup); - if (cwd orig_cwd) { - chdir2(orig_cwd); - free(orig_cwd); - } - } - /* fill the child arg vector */ - construct_argc_argv(command_dup, NULL, command_num_args, child_argv); - child_argv[command_num_args] = NULL; - child = procve(child_argv[0], PROC_DETACHED|PROC_INHERIT_CWD, NULL, channel, NULL, NULL, 0, NULL, (const char**)child_argv); - free(child_argv); - free(command_dup); - if (cwd orig_cwd) { - chdir2(orig_cwd); - free(orig_cwd); - } - if (child 0) { - /* failed to fork() */ - /* clean up all the descriptors */ - for (i = 0; i ndesc; i++) { - close(descriptors[i].childend); - close(descriptors[i].parentend); - } - php_error_docref(NULL TSRMLS_CC, E_WARNING, procve failed - %s, strerror(errno)); - goto exit_fail; - } #else # error You lose (configure should not have let you get here) #endif -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard proc_open.c
sniper Mon Jun 20 07:10:13 2005 EDT Modified files: /php-src/ext/standard proc_open.c Log: typo http://cvs.php.net/diff.php/php-src/ext/standard/proc_open.c?r1=1.33r2=1.34ty=u Index: php-src/ext/standard/proc_open.c diff -u php-src/ext/standard/proc_open.c:1.33 php-src/ext/standard/proc_open.c:1.34 --- php-src/ext/standard/proc_open.c:1.33 Thu Apr 7 19:07:45 2005 +++ php-src/ext/standard/proc_open.cMon Jun 20 07:10:11 2005 @@ -15,7 +15,7 @@ | Author: Wez Furlong [EMAIL PROTECTED] | +--+ */ -/* $Id: proc_open.c,v 1.33 2005/04/07 23:07:45 iliaa Exp $ */ +/* $Id: proc_open.c,v 1.34 2005/06/20 11:10:11 sniper Exp $ */ #if 0 (defined(__linux__) || defined(sun) || defined(__IRIX__)) # define _BSD_SOURCE /* linux wants this when XOPEN mode is on */ @@ -697,7 +697,7 @@ descriptors[ndesc].parentend = dup(dev_ptmx); descriptors[ndesc].mode_flags = O_RDWR; #else - php_error_docref(NULL TSRMLS_CC, E_WARNING, pty pseudo terminal is not support on this system); + php_error_docref(NULL TSRMLS_CC, E_WARNING, pty pseudo terminal not supported on this system); goto exit_fail; #endif } else { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard proc_open.c
iliaa Thu Apr 7 19:07:46 2005 EDT Modified files: /php-src/ext/standard proc_open.c Log: Fixed bug #32533 (proc_get_status() returns the incorrect process status). http://cvs.php.net/diff.php/php-src/ext/standard/proc_open.c?r1=1.32r2=1.33ty=u Index: php-src/ext/standard/proc_open.c diff -u php-src/ext/standard/proc_open.c:1.32 php-src/ext/standard/proc_open.c:1.33 --- php-src/ext/standard/proc_open.c:1.32 Mon Mar 7 11:17:12 2005 +++ php-src/ext/standard/proc_open.cThu Apr 7 19:07:45 2005 @@ -15,7 +15,7 @@ | Author: Wez Furlong [EMAIL PROTECTED] | +--+ */ -/* $Id: proc_open.c,v 1.32 2005/03/07 16:17:12 iliaa Exp $ */ +/* $Id: proc_open.c,v 1.33 2005/04/07 23:07:45 iliaa Exp $ */ #if 0 (defined(__linux__) || defined(sun) || defined(__IRIX__)) # define _BSD_SOURCE /* linux wants this when XOPEN mode is on */ @@ -402,6 +402,7 @@ exitcode = WEXITSTATUS(wstatus); } if (WIFSIGNALED(wstatus)) { + running = 0; signaled = 1; #ifdef NETWARE termsig = WIFTERMSIG(wstatus); @@ -413,7 +414,7 @@ stopped = 1; stopsig = WSTOPSIG(wstatus); } - } else { + } else if (wait_pid == -1) { running = 0; } #endif -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard proc_open.c
hyanantha Mon Feb 21 04:50:48 2005 EDT Modified files: /php-src/ext/standard proc_open.c Log: In NetWare LibC WTERMSIG is avaliable as WIFTERMSIG http://cvs.php.net/diff.php/php-src/ext/standard/proc_open.c?r1=1.30r2=1.31ty=u Index: php-src/ext/standard/proc_open.c diff -u php-src/ext/standard/proc_open.c:1.30 php-src/ext/standard/proc_open.c:1.31 --- php-src/ext/standard/proc_open.c:1.30 Wed Nov 10 14:47:15 2004 +++ php-src/ext/standard/proc_open.cMon Feb 21 04:50:48 2005 @@ -15,7 +15,7 @@ | Author: Wez Furlong [EMAIL PROTECTED] | +--+ */ -/* $Id: proc_open.c,v 1.30 2004/11/10 19:47:15 wez Exp $ */ +/* $Id: proc_open.c,v 1.31 2005/02/21 09:50:48 hyanantha Exp $ */ #if 0 (defined(__linux__) || defined(sun) || defined(__IRIX__)) # define _BSD_SOURCE /* linux wants this when XOPEN mode is on */ @@ -403,7 +403,11 @@ } if (WIFSIGNALED(wstatus)) { signaled = 1; +#ifdef NETWARE + termsig = WIFTERMSIG(wstatus); +#else termsig = WTERMSIG(wstatus); +#endif } if (WIFSTOPPED(wstatus)) { stopped = 1; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard proc_open.c
wez Wed Nov 10 14:47:17 2004 EDT Modified files: /php-src/ext/standard proc_open.c Log: Fix leaking handle. Thanks to ilya77 at gmail dot com http://cvs.php.net/diff.php/php-src/ext/standard/proc_open.c?r1=1.29r2=1.30ty=u Index: php-src/ext/standard/proc_open.c diff -u php-src/ext/standard/proc_open.c:1.29 php-src/ext/standard/proc_open.c:1.30 --- php-src/ext/standard/proc_open.c:1.29 Wed Sep 29 02:04:36 2004 +++ php-src/ext/standard/proc_open.cWed Nov 10 14:47:15 2004 @@ -15,7 +15,7 @@ | Author: Wez Furlong [EMAIL PROTECTED] | +--+ */ -/* $Id: proc_open.c,v 1.29 2004/09/29 06:04:36 hyanantha Exp $ */ +/* $Id: proc_open.c,v 1.30 2004/11/10 19:47:15 wez Exp $ */ #if 0 (defined(__linux__) || defined(sun) || defined(__IRIX__)) # define _BSD_SOURCE /* linux wants this when XOPEN mode is on */ @@ -219,6 +219,7 @@ WaitForSingleObject(proc-child, INFINITE); GetExitCodeProcess(proc-child, wstatus); FG(pclose_ret) = wstatus; + CloseHandle(proc-child); #elif HAVE_SYS_WAIT_H -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard proc_open.c
hyanantha Wed Sep 29 02:04:37 2004 EDT Modified files: /php-src/ext/standard proc_open.c Log: implemented proc_open for NETWARE http://cvs.php.net/diff.php/php-src/ext/standard/proc_open.c?r1=1.28r2=1.29ty=u Index: php-src/ext/standard/proc_open.c diff -u php-src/ext/standard/proc_open.c:1.28 php-src/ext/standard/proc_open.c:1.29 --- php-src/ext/standard/proc_open.c:1.28 Wed Jun 16 19:57:25 2004 +++ php-src/ext/standard/proc_open.cWed Sep 29 02:04:36 2004 @@ -15,7 +15,7 @@ | Author: Wez Furlong [EMAIL PROTECTED] | +--+ */ -/* $Id: proc_open.c,v 1.28 2004/06/16 23:57:25 abies Exp $ */ +/* $Id: proc_open.c,v 1.29 2004/09/29 06:04:36 hyanantha Exp $ */ #if 0 (defined(__linux__) || defined(sun) || defined(__IRIX__)) # define _BSD_SOURCE /* linux wants this when XOPEN mode is on */ @@ -35,6 +35,11 @@ #include php_globals.h #include SAPI.h +#ifdef NETWARE +#include proc.h +#include library.h +#endif + #if HAVE_SYS_WAIT_H #include sys/wait.h #endif @@ -478,6 +483,13 @@ char *command_with_cmd; UINT old_error_mode; #endif +#ifdef NETWARE + char** child_argv = NULL; + char* command_dup = NULL; + char* orig_cwd = NULL; + int command_num_args = 0; + wiring_t channel; +#endif php_process_id_t child; struct php_process_handle *proc; int is_persistent = 0; /* TODO: ensure that persistent procs will work */ @@ -810,6 +822,46 @@ goto exit_fail; + } +#elif defined(NETWARE) + if (cwd) { + orig_cwd = getcwd(NULL, PATH_MAX); + chdir2(cwd); + } + channel.infd = descriptors[0].childend; + channel.outfd = descriptors[1].childend; + channel.errfd = -1; + /* Duplicate the command as processing downwards will modify it*/ + command_dup = strdup(command); + /* get a number of args */ + construct_argc_argv(command_dup, NULL, command_num_args, NULL); + child_argv = (char**) malloc((command_num_args + 1) * sizeof(char*)); + if(!child_argv) { + free(command_dup); + if (cwd orig_cwd) { + chdir2(orig_cwd); + free(orig_cwd); + } + } + /* fill the child arg vector */ + construct_argc_argv(command_dup, NULL, command_num_args, child_argv); + child_argv[command_num_args] = NULL; + child = procve(child_argv[0], PROC_DETACHED|PROC_INHERIT_CWD, NULL, channel, NULL, NULL, 0, NULL, (const char**)child_argv); + free(child_argv); + free(command_dup); + if (cwd orig_cwd) { + chdir2(orig_cwd); + free(orig_cwd); + } + if (child 0) { + /* failed to fork() */ + /* clean up all the descriptors */ + for (i = 0; i ndesc; i++) { + close(descriptors[i].childend); + close(descriptors[i].parentend); + } + php_error_docref(NULL TSRMLS_CC, E_WARNING, procve failed - %s, strerror(errno)); + goto exit_fail; } #else # error You lose (configure should not have let you get here) -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src /ext/standard proc_open.c
On Fri, 28 May 2004, Wez Furlong wrote: wez Fri May 28 09:25:51 2004 EDT Modified files: /php-src/ext/standard proc_open.c Log: Hopefully resolve proc_open build issues. If proc_open.c is compiled by default (it currently is), you are taking a huge risk here. To put it differently, Hopefully does not break the PHP 5 release (fingers crossed). #ifdef-based portability solutions are infinitely inferior to autoconf-checks, because they only mature by breaking the build for someone to initiate a feedback cycle. Doing this for an initial, widely anticipated release of a product is basically a guarantee for a lot of such feedback. The current platform check for linux, sun, and irix will catch a huge number of systems which either don't support pts or have not them enabled. Are there any compelling reasons why you would not want to do this properly? I also just had a quick look at the code. It assumes that if a C library contains code for grantpt etc, that the actual system also has a working /dev/ptmx. This assumption is, of course, completely unreliable. For example, the default Linux 2.4 kernel setting is pts disabled -- although glibc contains the support code you check for. Thus, the current code will fail on a default Linux kernel. With other words: The pts support of proc_open.c is anything but mature and should not be enabled for the initial PHP 5 release. - Sascha -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard proc_open.c
wez Sat May 29 05:27:18 2004 EDT Modified files: /php-src/ext/standard proc_open.c Log: Turn this off then http://cvs.php.net/diff.php/php-src/ext/standard/proc_open.c?r1=1.26r2=1.27ty=u Index: php-src/ext/standard/proc_open.c diff -u php-src/ext/standard/proc_open.c:1.26 php-src/ext/standard/proc_open.c:1.27 --- php-src/ext/standard/proc_open.c:1.26 Fri May 28 20:30:11 2004 +++ php-src/ext/standard/proc_open.cSat May 29 05:27:18 2004 @@ -15,9 +15,9 @@ | Author: Wez Furlong [EMAIL PROTECTED] | +--+ */ -/* $Id: proc_open.c,v 1.26 2004/05/29 00:30:11 wez Exp $ */ +/* $Id: proc_open.c,v 1.27 2004/05/29 09:27:18 wez Exp $ */ -#if defined(__linux__) || defined(sun) || defined(__IRIX__) +#if 0 (defined(__linux__) || defined(sun) || defined(__IRIX__)) # define _BSD_SOURCE /* linux wants this when XOPEN mode is on */ # define _BSD_COMPAT /* irix: uint */ # define _XOPEN_SOURCE 500 /* turn on Unix98 */ @@ -56,7 +56,7 @@ * */ #ifdef PHP_CAN_SUPPORT_PROC_OPEN -#if HAVE_PTSNAME HAVE_GRANTPT HAVE_UNLOCKPT HAVE_SYS_IOCTL_H HAVE_TERMIOS_H +#if 0 HAVE_PTSNAME HAVE_GRANTPT HAVE_UNLOCKPT HAVE_SYS_IOCTL_H HAVE_TERMIOS_H # include sys/ioctl.h # include termios.h # define PHP_CAN_DO_PTS1 -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard proc_open.c
wez Fri May 28 09:25:51 2004 EDT Modified files: /php-src/ext/standard proc_open.c Log: Hopefully resolve proc_open build issues. If we need anything more elaborate than this, then we can move to a configure time check as Sascha suggests. http://cvs.php.net/diff.php/php-src/ext/standard/proc_open.c?r1=1.24r2=1.25ty=u Index: php-src/ext/standard/proc_open.c diff -u php-src/ext/standard/proc_open.c:1.24 php-src/ext/standard/proc_open.c:1.25 --- php-src/ext/standard/proc_open.c:1.24 Wed May 26 10:55:32 2004 +++ php-src/ext/standard/proc_open.cFri May 28 09:25:51 2004 @@ -15,12 +15,14 @@ | Author: Wez Furlong [EMAIL PROTECTED] | +--+ */ -/* $Id: proc_open.c,v 1.24 2004/05/26 14:55:32 wez Exp $ */ +/* $Id: proc_open.c,v 1.25 2004/05/28 13:25:51 wez Exp $ */ -#define _XOPEN_SOURCE 500 -#define __EXTENSIONS__ 1 -#define _BSD_SOURCE -#define _OSF_SOURCE +#if defined(__linux__) || defined(sun) || defined(__IRIX__) +# define _BSD_SOURCE /* linux wants this when XOPEN mode is on */ +# define _BSD_COMPAT /* irix: uint */ +# define _XOPEN_SOURCE 500 /* turn on Unix98 */ +# define __EXTENSIONS__1 /* Solaris: uint */ +#endif #include php.h #include stdio.h -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard proc_open.c
wez Wed May 26 10:55:32 2004 EDT Modified files: /php-src/ext/standard proc_open.c Log: Apparently it is better to specify 500 here for unix98 bits and pieces. http://cvs.php.net/diff.php/php-src/ext/standard/proc_open.c?r1=1.23r2=1.24ty=u Index: php-src/ext/standard/proc_open.c diff -u php-src/ext/standard/proc_open.c:1.23 php-src/ext/standard/proc_open.c:1.24 --- php-src/ext/standard/proc_open.c:1.23 Sun May 9 07:08:04 2004 +++ php-src/ext/standard/proc_open.cWed May 26 10:55:32 2004 @@ -15,11 +15,12 @@ | Author: Wez Furlong [EMAIL PROTECTED] | +--+ */ -/* $Id: proc_open.c,v 1.23 2004/05/09 11:08:04 stas Exp $ */ +/* $Id: proc_open.c,v 1.24 2004/05/26 14:55:32 wez Exp $ */ -#define _XOPEN_SOURCE +#define _XOPEN_SOURCE 500 #define __EXTENSIONS__ 1 #define _BSD_SOURCE +#define _OSF_SOURCE #include php.h #include stdio.h @@ -52,7 +53,6 @@ * around the alternate code. * */ #ifdef PHP_CAN_SUPPORT_PROC_OPEN - #if HAVE_PTSNAME HAVE_GRANTPT HAVE_UNLOCKPT HAVE_SYS_IOCTL_H HAVE_TERMIOS_H # include sys/ioctl.h -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard proc_open.c
wez Sun May 2 07:13:08 2004 EDT Modified files: /php-src/ext/standard proc_open.c Log: Fix Bug #28251 http://cvs.php.net/diff.php/php-src/ext/standard/proc_open.c?r1=1.21r2=1.22ty=u Index: php-src/ext/standard/proc_open.c diff -u php-src/ext/standard/proc_open.c:1.21 php-src/ext/standard/proc_open.c:1.22 --- php-src/ext/standard/proc_open.c:1.21 Mon Apr 19 11:07:30 2004 +++ php-src/ext/standard/proc_open.cSun May 2 07:13:08 2004 @@ -15,7 +15,7 @@ | Author: Wez Furlong [EMAIL PROTECTED] | +--+ */ -/* $Id: proc_open.c,v 1.21 2004/04/19 15:07:30 wez Exp $ */ +/* $Id: proc_open.c,v 1.22 2004/05/02 11:13:08 wez Exp $ */ #define _XOPEN_SOURCE #define _BSD_SOURCE @@ -54,9 +54,11 @@ #if HAVE_PTSNAME HAVE_GRANTPT HAVE_UNLOCKPT HAVE_SYS_IOCTL_H HAVE_TERMIOS_H -# define PHP_CAN_DO_PTS1 # include sys/ioctl.h # include termios.h +# ifdef TIOCNOTTY +# define PHP_CAN_DO_PTS 1 +# endif #endif #include proc_open.h -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard proc_open.c
sniper Sat Dec 6 05:48:57 2003 EDT Modified files: /php-src/ext/standard proc_open.c Log: fix proto Index: php-src/ext/standard/proc_open.c diff -u php-src/ext/standard/proc_open.c:1.18 php-src/ext/standard/proc_open.c:1.19 --- php-src/ext/standard/proc_open.c:1.18 Fri Dec 5 08:48:40 2003 +++ php-src/ext/standard/proc_open.cSat Dec 6 05:48:56 2003 @@ -15,7 +15,7 @@ | Author: Wez Furlong [EMAIL PROTECTED] | +--+ */ -/* $Id: proc_open.c,v 1.18 2003/12/05 13:48:40 wez Exp $ */ +/* $Id: proc_open.c,v 1.19 2003/12/06 10:48:56 sniper Exp $ */ #include stdio.h #include php.h @@ -444,7 +444,7 @@ }; /* }}} */ -/* {{{ proto resource proc_open(string command, array descriptorspec, array pipes [, string cwd [, array env] [, array other_options]]) +/* {{{ proto resource proc_open(string command, array descriptorspec, array pipes [, string cwd [, array env [, array other_options]]]) Run a process with more control over it's file descriptors */ PHP_FUNCTION(proc_open) { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard proc_open.c
wez Fri Dec 5 08:48:40 2003 EDT Modified files: /php-src/ext/standard proc_open.c Log: fix unix build Index: php-src/ext/standard/proc_open.c diff -u php-src/ext/standard/proc_open.c:1.17 php-src/ext/standard/proc_open.c:1.18 --- php-src/ext/standard/proc_open.c:1.17 Fri Dec 5 08:45:00 2003 +++ php-src/ext/standard/proc_open.cFri Dec 5 08:48:40 2003 @@ -15,7 +15,7 @@ | Author: Wez Furlong [EMAIL PROTECTED] | +--+ */ -/* $Id: proc_open.c,v 1.17 2003/12/05 13:45:00 wez Exp $ */ +/* $Id: proc_open.c,v 1.18 2003/12/05 13:48:40 wez Exp $ */ #include stdio.h #include php.h @@ -467,11 +467,11 @@ SECURITY_ATTRIBUTES security; char *command_with_cmd; UINT old_error_mode; - int suppress_errors = 0; #endif php_process_id_t child; struct php_process_handle *proc; int is_persistent = 0; /* TODO: ensure that persistent procs will work */ + int suppress_errors = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, saz|s!a!a!, command, command_len, descriptorspec, pipes, cwd, cwd_len, environment, -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard proc_open.c
moriyoshi Sat Jul 12 02:50:32 2003 EDT Modified files: /php-src/ext/standard proc_open.c Log: Fixed leaks that occurs if the third parameter already contains a valid value. Index: php-src/ext/standard/proc_open.c diff -u php-src/ext/standard/proc_open.c:1.12 php-src/ext/standard/proc_open.c:1.13 --- php-src/ext/standard/proc_open.c:1.12 Tue Jun 10 16:03:38 2003 +++ php-src/ext/standard/proc_open.cSat Jul 12 02:50:32 2003 @@ -15,7 +15,7 @@ | Author: Wez Furlong [EMAIL PROTECTED] | +--+ */ -/* $Id: proc_open.c,v 1.12 2003/06/10 20:03:38 imajes Exp $ */ +/* $Id: proc_open.c,v 1.13 2003/07/12 06:50:32 moriyoshi Exp $ */ #include stdio.h #include php.h @@ -470,7 +470,7 @@ struct php_process_handle *proc; int is_persistent = 0; /* TODO: ensure that persistent procs will work */ - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, saz/|s!a!, command, + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, saz|s!a!, command, command_len, descriptorspec, pipes, cwd, cwd_len, environment) == FAILURE) { RETURN_FALSE; } @@ -737,6 +737,10 @@ proc-child = child; proc-env = env; + if (pipes != NULL) { + zval_dtor(pipes); + } + MAKE_STD_ZVAL(pipes); array_init(pipes); /* clean up all the child ends and then open streams on the parent -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard proc_open.c
moriyoshi Sat Jul 12 02:54:03 2003 EDT Modified files: /php-src/ext/standard proc_open.c Log: Oops, this is not needed though. Index: php-src/ext/standard/proc_open.c diff -u php-src/ext/standard/proc_open.c:1.13 php-src/ext/standard/proc_open.c:1.14 --- php-src/ext/standard/proc_open.c:1.13 Sat Jul 12 02:50:32 2003 +++ php-src/ext/standard/proc_open.cSat Jul 12 02:54:03 2003 @@ -15,7 +15,7 @@ | Author: Wez Furlong [EMAIL PROTECTED] | +--+ */ -/* $Id: proc_open.c,v 1.13 2003/07/12 06:50:32 moriyoshi Exp $ */ +/* $Id: proc_open.c,v 1.14 2003/07/12 06:54:03 moriyoshi Exp $ */ #include stdio.h #include php.h @@ -740,7 +740,6 @@ if (pipes != NULL) { zval_dtor(pipes); } - MAKE_STD_ZVAL(pipes); array_init(pipes); /* clean up all the child ends and then open streams on the parent -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard proc_open.c
moriyoshi Sat Jul 12 03:01:30 2003 EDT Modified files: /php-src/ext/standard proc_open.c Log: Add folding markers Index: php-src/ext/standard/proc_open.c diff -u php-src/ext/standard/proc_open.c:1.14 php-src/ext/standard/proc_open.c:1.15 --- php-src/ext/standard/proc_open.c:1.14 Sat Jul 12 02:54:03 2003 +++ php-src/ext/standard/proc_open.cSat Jul 12 03:01:30 2003 @@ -15,7 +15,7 @@ | Author: Wez Furlong [EMAIL PROTECTED] | +--+ */ -/* $Id: proc_open.c,v 1.14 2003/07/12 06:54:03 moriyoshi Exp $ */ +/* $Id: proc_open.c,v 1.15 2003/07/12 07:01:30 moriyoshi Exp $ */ #include stdio.h #include php.h @@ -179,7 +179,7 @@ } /* }}} */ - +/* {{{ proc_open_rsrc_dtor */ static void proc_open_rsrc_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC) { struct php_process_handle *proc = (struct php_process_handle*)rsrc-ptr; @@ -227,6 +227,7 @@ pefree(proc, proc-is_persistent); } +/* }}} */ /* {{{ php_make_safe_mode_command */ static int php_make_safe_mode_command(char *cmd, char **safecmd, int is_persistent TSRMLS_DC) @@ -290,12 +291,13 @@ } /* }}} */ +/* {{{ PHP_MINIT_FUNCTION(proc_open) */ PHP_MINIT_FUNCTION(proc_open) { le_proc_open = zend_register_list_destructors_ex(proc_open_rsrc_dtor, NULL, process, module_number); return SUCCESS; } - +/* }}} */ /* {{{ proto int proc_terminate(resource process [, long signal]) kill a process opened by proc_open */ @@ -321,7 +323,6 @@ RETURN_LONG(FG(pclose_ret)); } /* }}} */ - /* {{{ proto int proc_close(resource process) close a process opened by proc_open */ -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php