diff options
author | Paul Smith <psmith@gnu.org> | 2005-08-08 05:08:00 +0000 |
---|---|---|
committer | Paul Smith <psmith@gnu.org> | 2005-08-08 05:08:00 +0000 |
commit | b237dff7753f444c4e0e8ea6bb1929243e45b310 (patch) | |
tree | 8ccb5752696b899aee3a1b7cce24936d698a835c /commands.c | |
parent | a53903e4c32f47ce3e20edd9114f4fabd028d13c (diff) | |
download | gunmake-b237dff7753f444c4e0e8ea6bb1929243e45b310.tar.gz |
- Fixed a bug reported by Michael Matz regarding handling of parallel
jobs after a failed job.
- Enhancements to WINDOWS32 code from Eli Zaretskii.
- Add Microsoft Project files from J. Grant.
Diffstat (limited to 'commands.c')
-rw-r--r-- | commands.c | 32 |
1 files changed, 30 insertions, 2 deletions
@@ -23,6 +23,10 @@ Boston, MA 02111-1307, USA. */ #include "variable.h" #include "job.h" #include "commands.h" +#ifdef WINDOWS32 +#include <windows.h> +#include "w32err.h" +#endif #if VMS # define FILE_LIST_SEPARATOR ',' @@ -420,6 +424,27 @@ fatal_error_signal (int sig) exit (10); #else /* not Amiga */ +#ifdef WINDOWS32 + extern HANDLE main_thread; + + /* Windows creates a sperate thread for handling Ctrl+C, so we need + to suspend the main thread, or else we will have race conditions + when both threads call reap_children. */ + if (main_thread) + { + DWORD susp_count = SuspendThread (main_thread); + + if (susp_count != 0) + fprintf (stderr, "SuspendThread: suspend count = %ld\n", susp_count); + else if (susp_count == (DWORD)-1) + { + DWORD ierr = GetLastError (); + + fprintf (stderr, "SuspendThread: error %ld: %s\n", + ierr, map_windows32_error_to_string (ierr)); + } + } +#endif handling_fatal_signal = 1; /* Set the handling for this signal to the default. @@ -482,8 +507,11 @@ fatal_error_signal (int sig) #endif #ifdef WINDOWS32 - /* Cannot call W32_kill with a pid (it needs a handle) */ - exit (EXIT_FAILURE); + if (main_thread) + CloseHandle (main_thread); + /* Cannot call W32_kill with a pid (it needs a handle). The exit + status of 130 emulates what happens in Bash. */ + exit (130); #else /* Signal the same code; this time it will really be fatal. The signal will be unblocked when we return and arrive then to kill us. */ |