From 251b711eac37ebe392942758d20201ed66f990e5 Mon Sep 17 00:00:00 2001 From: Pierre Joye Date: Tue, 9 Jun 2009 14:07:06 +0000 Subject: [PATCH] - MFB: #41874, separate STDOUT and STDERR in exec functions --- ext/standard/proc_open.c | 12 +++++++++--- ext/standard/tests/file/bug41874.phpt | 22 ++++++++++++++++++++++ ext/standard/tests/file/bug41874_1.phpt | 16 ++++++++++++++++ ext/standard/tests/file/bug41874_2.phpt | 17 +++++++++++++++++ ext/standard/tests/file/bug41874_3.phpt | 16 ++++++++++++++++ 5 files changed, 80 insertions(+), 3 deletions(-) create mode 100644 ext/standard/tests/file/bug41874.phpt create mode 100644 ext/standard/tests/file/bug41874_1.phpt create mode 100644 ext/standard/tests/file/bug41874_2.phpt create mode 100644 ext/standard/tests/file/bug41874_3.phpt diff --git a/ext/standard/proc_open.c b/ext/standard/proc_open.c index 73b69ad393..9821ea3447 100644 --- a/ext/standard/proc_open.c +++ b/ext/standard/proc_open.c @@ -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 index 0000000000..c6f9fed675 --- /dev/null +++ b/ext/standard/tests/file/bug41874.phpt @@ -0,0 +1,22 @@ +--TEST-- +bug #41874 (Separate STDOUT and STDERR in exec functions) +--CREDITS-- +Venkat Raman Don +--SKIPIF-- + +--FILE-- + +--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 index 0000000000..c6ddef8066 --- /dev/null +++ b/ext/standard/tests/file/bug41874_1.phpt @@ -0,0 +1,16 @@ +--TEST-- +bug #41874 (Separate STDOUT and STDERR in exec functions) +--CREDITS-- +Venkat Raman Don +--SKIPIF-- + +--FILE-- + +--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 index 0000000000..5d7b7cad8d --- /dev/null +++ b/ext/standard/tests/file/bug41874_2.phpt @@ -0,0 +1,17 @@ +--TEST-- +bug #41874 (Separate STDOUT and STDERR in exec functions) +--CREDITS-- +Venkat Raman Don +--SKIPIF-- + +--FILE-- + +--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 index 0000000000..4d7b139ad7 --- /dev/null +++ b/ext/standard/tests/file/bug41874_3.phpt @@ -0,0 +1,16 @@ +--TEST-- +bug #41874 (Separate STDOUT and STDERR in exec functions) +--CREDITS-- +Venkat Raman Don +--SKIPIF-- + +--FILE-- + +--EXPECT-- +The system cannot find the drive specified. \ No newline at end of file -- 2.50.1