aboutsummaryrefslogtreecommitdiff
path: root/winsup/cygwin/spawn.cc
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2005-06-18 01:27:06 +0000
committerChristopher Faylor <me@cgf.cx>2005-06-18 01:27:06 +0000
commit2bc6be1edace6a5465a920510a69dc459f70e5dd (patch)
tree5c2f4c37f3fd826899dc4d5347b49b01db62ec62 /winsup/cygwin/spawn.cc
parentb3ba5059dab9a7687d79ed591fc84591b315b1b3 (diff)
downloadnewlib-2bc6be1edace6a5465a920510a69dc459f70e5dd.zip
newlib-2bc6be1edace6a5465a920510a69dc459f70e5dd.tar.gz
newlib-2bc6be1edace6a5465a920510a69dc459f70e5dd.tar.bz2
* spawn.cc (spawn_guts): Detect when executing a 16-bit application and avoid
setting the process pipe since this causes conniptions in Windows 9x.
Diffstat (limited to 'winsup/cygwin/spawn.cc')
-rw-r--r--winsup/cygwin/spawn.cc13
1 files changed, 9 insertions, 4 deletions
diff --git a/winsup/cygwin/spawn.cc b/winsup/cygwin/spawn.cc
index 654b1d4..c8efe8a 100644
--- a/winsup/cygwin/spawn.cc
+++ b/winsup/cygwin/spawn.cc
@@ -402,6 +402,7 @@ spawn_guts (const char * prog_arg, const char *const *argv,
av newargv (ac, argv);
+ bool msdos_exe = false;
int null_app_name = 0;
if (ac == 3 && argv[1][0] == '/' && argv[1][1] == 'c' &&
(iscmd (argv[0], "command.com") || iscmd (argv[0], "cmd.exe")))
@@ -433,7 +434,7 @@ spawn_guts (const char * prog_arg, const char *const *argv,
/* If the file name ends in either .exe, .com, .bat, or .cmd we assume
that it is NOT a script file */
- while (*ext == '\0')
+ while (*ext == '\0' || strcasematch (ext, ".exe"))
{
HANDLE hnd = CreateFile (real_path, GENERIC_READ,
FILE_SHARE_READ | FILE_SHARE_WRITE,
@@ -459,7 +460,11 @@ spawn_guts (const char * prog_arg, const char *const *argv,
CloseHandle (hnd);
if (buf[0] == 'M' && buf[1] == 'Z')
- break;
+ {
+ unsigned off = (unsigned char) buf[0x18] | (((unsigned char) buf[0x19]) << 8);
+ msdos_exe = off < sizeof (IMAGE_DOS_HEADER);
+ break;
+ }
debug_printf ("%s is a script", (char *) real_path);
@@ -617,7 +622,7 @@ spawn_guts (const char * prog_arg, const char *const *argv,
si.hStdError = handle (2, 1); /* Get output handle */
si.cb = sizeof (si);
- int flags = CREATE_DEFAULT_ERROR_MODE | GetPriorityClass (hMainProc);
+ int flags = CREATE_DEFAULT_ERROR_MODE | GetPriorityClass (hMainProc) | CREATE_SEPARATE_WOW_VDM;
if (mode == _P_DETACH || !set_console_state_for_spawn ())
flags |= DETACHED_PROCESS;
@@ -807,7 +812,7 @@ spawn_guts (const char * prog_arg, const char *const *argv,
on this fact when we exit. dup_proc_pipe will close our end of the pipe.
Note that wr_proc_pipe may also be == INVALID_HANDLE_VALUE. That will make
dup_proc_pipe essentially a no-op. */
- if (myself->wr_proc_pipe)
+ if (!msdos_exe && myself->wr_proc_pipe)
{
myself->sync_proc_pipe (); /* Make sure that we own wr_proc_pipe
just in case we've been previously