From abef91dc2a17d32ab16dda20bbf61c36ea21cde6 Mon Sep 17 00:00:00 2001 From: cgf Date: Sat, 18 Jun 2005 01:36:15 +0000 Subject: [PATCH] * wincap.h (wincaps::detect_win16_exe): Declare. (wincapc::detect_win16_exe): Implement. * wincap.cc: Populate detect_win16_exe where appropriate. * spawn.cc (spawn_guts): Only go out of the way to detect 16-bit apps on systems which are flummoxed by them. --- winsup/cygwin/ChangeLog | 8 ++++++++ winsup/cygwin/spawn.cc | 8 ++++---- winsup/cygwin/wincap.cc | 36 ++++++++++++++++++++++++------------ winsup/cygwin/wincap.h | 2 ++ 4 files changed, 38 insertions(+), 16 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index ead7b14b04..5d94cff016 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,5 +1,13 @@ 2005-06-17 Christopher Faylor + * wincap.h (wincaps::detect_win16_exe): Declare. + (wincapc::detect_win16_exe): Implement. + * wincap.cc: Populate detect_win16_exe where appropriate. + * spawn.cc (spawn_guts): Only go out of the way to detect 16-bit apps + on systems which are flummoxed by them. + +2005-06-17 Christopher Faylor + * spawn.cc (spawn_guts): Detect when executing a 16-bit application and avoid setting the process pipe since this causes conniptions in Windows 9x. diff --git a/winsup/cygwin/spawn.cc b/winsup/cygwin/spawn.cc index c8efe8a06c..7f4d8fb0fb 100644 --- a/winsup/cygwin/spawn.cc +++ b/winsup/cygwin/spawn.cc @@ -402,7 +402,7 @@ spawn_guts (const char * prog_arg, const char *const *argv, av newargv (ac, argv); - bool msdos_exe = false; + bool win16_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"))) @@ -434,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' || strcasematch (ext, ".exe")) + while (*ext == '\0' || (wincap.detect_win16_exe () && strcasematch (ext, ".exe"))) { HANDLE hnd = CreateFile (real_path, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, @@ -462,7 +462,7 @@ spawn_guts (const char * prog_arg, const char *const *argv, if (buf[0] == 'M' && buf[1] == 'Z') { unsigned off = (unsigned char) buf[0x18] | (((unsigned char) buf[0x19]) << 8); - msdos_exe = off < sizeof (IMAGE_DOS_HEADER); + win16_exe = off < sizeof (IMAGE_DOS_HEADER); break; } @@ -812,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 (!msdos_exe && myself->wr_proc_pipe) + if (!win16_exe && myself->wr_proc_pipe) { myself->sync_proc_pipe (); /* Make sure that we own wr_proc_pipe just in case we've been previously diff --git a/winsup/cygwin/wincap.cc b/winsup/cygwin/wincap.cc index 9a790b0878..0d04047022 100644 --- a/winsup/cygwin/wincap.cc +++ b/winsup/cygwin/wincap.cc @@ -57,7 +57,8 @@ static NO_COPY wincaps wincap_unknown = { has_ioctl_storage_get_media_types_ex:false, start_proc_suspended:true, has_extended_priority_class:false, - has_guid_volumes:false + has_guid_volumes:false, + detect_win16_exe:true }; static NO_COPY wincaps wincap_95 = { @@ -106,7 +107,8 @@ static NO_COPY wincaps wincap_95 = { has_ioctl_storage_get_media_types_ex:false, start_proc_suspended:true, has_extended_priority_class:false, - has_guid_volumes:false + has_guid_volumes:false, + detect_win16_exe:true }; static NO_COPY wincaps wincap_95osr2 = { @@ -155,7 +157,8 @@ static NO_COPY wincaps wincap_95osr2 = { has_ioctl_storage_get_media_types_ex:false, start_proc_suspended:true, has_extended_priority_class:false, - has_guid_volumes:false + has_guid_volumes:false, + detect_win16_exe:true }; static NO_COPY wincaps wincap_98 = { @@ -204,7 +207,8 @@ static NO_COPY wincaps wincap_98 = { has_ioctl_storage_get_media_types_ex:false, start_proc_suspended:true, has_extended_priority_class:false, - has_guid_volumes:false + has_guid_volumes:false, + detect_win16_exe:true }; static NO_COPY wincaps wincap_98se = { @@ -253,7 +257,8 @@ static NO_COPY wincaps wincap_98se = { has_ioctl_storage_get_media_types_ex:false, start_proc_suspended:true, has_extended_priority_class:false, - has_guid_volumes:false + has_guid_volumes:false, + detect_win16_exe:true }; static NO_COPY wincaps wincap_me = { @@ -302,7 +307,8 @@ static NO_COPY wincaps wincap_me = { has_ioctl_storage_get_media_types_ex:false, start_proc_suspended:true, has_extended_priority_class:false, - has_guid_volumes:false + has_guid_volumes:false, + detect_win16_exe:true }; static NO_COPY wincaps wincap_nt3 = { @@ -351,7 +357,8 @@ static NO_COPY wincaps wincap_nt3 = { has_ioctl_storage_get_media_types_ex:false, start_proc_suspended:false, has_extended_priority_class:false, - has_guid_volumes:false + has_guid_volumes:false, + detect_win16_exe:false }; static NO_COPY wincaps wincap_nt4 = { @@ -400,7 +407,8 @@ static NO_COPY wincaps wincap_nt4 = { has_ioctl_storage_get_media_types_ex:false, start_proc_suspended:false, has_extended_priority_class:false, - has_guid_volumes:false + has_guid_volumes:false, + detect_win16_exe:false }; static NO_COPY wincaps wincap_nt4sp4 = { @@ -449,7 +457,8 @@ static NO_COPY wincaps wincap_nt4sp4 = { has_ioctl_storage_get_media_types_ex:false, start_proc_suspended:false, has_extended_priority_class:false, - has_guid_volumes:false + has_guid_volumes:false, + detect_win16_exe:false }; static NO_COPY wincaps wincap_2000 = { @@ -498,7 +507,8 @@ static NO_COPY wincaps wincap_2000 = { has_ioctl_storage_get_media_types_ex:false, start_proc_suspended:false, has_extended_priority_class:true, - has_guid_volumes:true + has_guid_volumes:true, + detect_win16_exe:false }; static NO_COPY wincaps wincap_xp = { @@ -547,7 +557,8 @@ static NO_COPY wincaps wincap_xp = { has_ioctl_storage_get_media_types_ex:true, start_proc_suspended:false, has_extended_priority_class:true, - has_guid_volumes:true + has_guid_volumes:true, + detect_win16_exe:false }; static NO_COPY wincaps wincap_2003 = { @@ -596,7 +607,8 @@ static NO_COPY wincaps wincap_2003 = { has_ioctl_storage_get_media_types_ex:true, start_proc_suspended:false, has_extended_priority_class:true, - has_guid_volumes:true + has_guid_volumes:true, + detect_win16_exe:false }; wincapc wincap; diff --git a/winsup/cygwin/wincap.h b/winsup/cygwin/wincap.h index 6d7d63ec9a..abb801da29 100644 --- a/winsup/cygwin/wincap.h +++ b/winsup/cygwin/wincap.h @@ -59,6 +59,7 @@ struct wincaps unsigned start_proc_suspended : 1; unsigned has_extended_priority_class : 1; unsigned has_guid_volumes : 1; + unsigned detect_win16_exe : 1; }; class wincapc @@ -122,6 +123,7 @@ public: bool IMPLEMENT (start_proc_suspended) bool IMPLEMENT (has_extended_priority_class) bool IMPLEMENT (has_guid_volumes) + bool IMPLEMENT (detect_win16_exe) #undef IMPLEMENT }; -- 2.11.0