# HG changeset patch # User Andrew Innes # Date 992257203 0 # Node ID 71e8b6ae114f1d9609f16866537c8a6d06d8ec3c # Parent 41f655ec596acf6c6e57f8ed9afd944cd28cdb7d (create_child): Add new parameter is_gui_app. (w32_executable_type): Add new parameter is_gui_app. (sys_spawnve): Use it. (sys_kill): Fake ^C for SIGINT, and ^Break (if possible) for SIGQUIT. This matches better how the signals are interpreted by MSVC compiled programs. (syms_of_ntproc): Update docstring. diff -r 41f655ec596a -r 71e8b6ae114f src/w32proc.c --- a/src/w32proc.c Mon Jun 11 10:08:57 2001 +0000 +++ b/src/w32proc.c Mon Jun 11 11:00:03 2001 +0000 @@ -304,7 +304,7 @@ static char * process_dir; static BOOL -create_child (char *exe, char *cmdline, char *env, +create_child (char *exe, char *cmdline, char *env, int is_gui_app, int * pPid, child_process *cp) { STARTUPINFO start; @@ -321,7 +321,7 @@ start.cb = sizeof (start); #ifdef HAVE_NTGUI - if (NILP (Vw32_start_process_show_window)) + if (NILP (Vw32_start_process_show_window) && !is_gui_app) start.dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW; else start.dwFlags = STARTF_USESTDHANDLES; @@ -571,7 +571,7 @@ } void -w32_executable_type (char * filename, int * is_dos_app, int * is_cygnus_app) +w32_executable_type (char * filename, int * is_dos_app, int * is_cygnus_app, int * is_gui_app) { file_data executable; char * p; @@ -579,6 +579,7 @@ /* Default values in case we can't tell for sure. */ *is_dos_app = FALSE; *is_cygnus_app = FALSE; + *is_gui_app = FALSE; if (!open_input_file (&executable, filename)) return; @@ -599,7 +600,7 @@ extension, which is defined in the registry. */ p = egetenv ("COMSPEC"); if (p) - w32_executable_type (p, is_dos_app, is_cygnus_app); + w32_executable_type (p, is_dos_app, is_cygnus_app, is_gui_app); } else { @@ -651,6 +652,11 @@ break; } } + + /* Check whether app is marked as a console or windowed (aka + GUI) app. Accept Posix and OS2 subsytem apps as console + apps. */ + *is_gui_app = (nt_header->OptionalHeader.Subsystem == IMAGE_SUBSYSTEM_WINDOWS_GUI); } } @@ -714,7 +720,7 @@ int arglen, numenv; int pid; child_process *cp; - int is_dos_app, is_cygnus_app; + int is_dos_app, is_cygnus_app, is_gui_app; int do_quoting = 0; char escape_char; /* We pass our process ID to our children by setting up an environment @@ -757,8 +763,11 @@ executable that is implicitly linked to the Cygnus dll (implying it was compiled with the Cygnus GNU toolchain and hence relies on cygwin.dll to parse the command line - we use this to decide how to - escape quote chars in command line args that must be quoted). */ - w32_executable_type (cmdname, &is_dos_app, &is_cygnus_app); + escape quote chars in command line args that must be quoted). + + Also determine whether it is a GUI app, so that we don't hide its + initial window unless specifically requested. */ + w32_executable_type (cmdname, &is_dos_app, &is_cygnus_app, &is_gui_app); /* On Windows 95, if cmdname is a DOS app, we invoke a helper application to start it by specifying the helper app as cmdname, @@ -992,7 +1001,7 @@ } /* Now create the process. */ - if (!create_child (cmdname, cmdline, env, &pid, cp)) + if (!create_child (cmdname, cmdline, env, is_gui_app, &pid, cp)) { delete_child (cp); errno = ENOEXEC; @@ -1383,18 +1392,19 @@ EnumWindows (find_child_console, (LPARAM) cp); } - if (sig == SIGINT) + if (sig == SIGINT || sig == SIGQUIT) { if (NILP (Vw32_start_process_share_console) && cp && cp->hwnd) { BYTE control_scan_code = (BYTE) MapVirtualKey (VK_CONTROL, 0); - BYTE vk_break_code = VK_CANCEL; + /* Fake Ctrl-C for SIGINT, and Ctrl-Break for SIGQUIT. */ + BYTE vk_break_code = (sig == SIGINT) ? 'C' : VK_CANCEL; BYTE break_scan_code = (BYTE) MapVirtualKey (vk_break_code, 0); HWND foreground_window; if (break_scan_code == 0) { - /* Fake Ctrl-C if we can't manage Ctrl-Break. */ + /* Fake Ctrl-C for SIGQUIT if we can't manage Ctrl-Break. */ vk_break_code = 'C'; break_scan_code = (BYTE) MapVirtualKey (vk_break_code, 0); } @@ -2154,7 +2164,8 @@ DEFVAR_LISP ("w32-start-process-show-window", &Vw32_start_process_show_window, "When nil, new child processes hide their windows.\n\ -When non-nil, they show their window in the method of their choice."); +When non-nil, they show their window in the method of their choice.\n\ +This variable doesn't affect GUI applications, which will never be hidden."); Vw32_start_process_show_window = Qnil; DEFVAR_LISP ("w32-start-process-share-console",