]> granicus.if.org Git - php/commitdiff
- MFB: #41874, separate STDOUT and STDERR in exec functions
authorPierre Joye <pajoye@php.net>
Tue, 9 Jun 2009 14:07:06 +0000 (14:07 +0000)
committerPierre Joye <pajoye@php.net>
Tue, 9 Jun 2009 14:07:06 +0000 (14:07 +0000)
ext/standard/proc_open.c
ext/standard/tests/file/bug41874.phpt [new file with mode: 0644]
ext/standard/tests/file/bug41874_1.phpt [new file with mode: 0644]
ext/standard/tests/file/bug41874_2.phpt [new file with mode: 0644]
ext/standard/tests/file/bug41874_3.phpt [new file with mode: 0644]

index 73b69ad393c443beb7bdff5cade57780a3d3cfff..9821ea34471a57be0c92a00ccf914fcf3cdd6af5 100644 (file)
@@ -444,6 +444,7 @@ PHP_FUNCTION(proc_open)
        STARTUPINFO si;
        BOOL newprocok;
        SECURITY_ATTRIBUTES security;
+       DWORD dwCreateFlags = 0;
        char *command_with_cmd;
        UINT old_error_mode;
 #endif
@@ -742,13 +743,18 @@ PHP_FUNCTION(proc_open)
                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() < 0x80000000 ? 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);
        }
 
diff --git a/ext/standard/tests/file/bug41874.phpt b/ext/standard/tests/file/bug41874.phpt
new file mode 100644 (file)
index 0000000..c6f9fed
--- /dev/null
@@ -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.
diff --git a/ext/standard/tests/file/bug41874_1.phpt b/ext/standard/tests/file/bug41874_1.phpt
new file mode 100644 (file)
index 0000000..c6ddef8
--- /dev/null
@@ -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
diff --git a/ext/standard/tests/file/bug41874_2.phpt b/ext/standard/tests/file/bug41874_2.phpt
new file mode 100644 (file)
index 0000000..5d7b7ca
--- /dev/null
@@ -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
diff --git a/ext/standard/tests/file/bug41874_3.phpt b/ext/standard/tests/file/bug41874_3.phpt
new file mode 100644 (file)
index 0000000..4d7b139
--- /dev/null
@@ -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
+system('cd 1:\\non_existant; dir nonexistant');
+?>
+--EXPECT--
+The system cannot find the drive specified.
\ No newline at end of file