From b237dff7753f444c4e0e8ea6bb1929243e45b310 Mon Sep 17 00:00:00 2001 From: Paul Smith Date: Mon, 8 Aug 2005 05:08:00 +0000 Subject: - 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. --- commands.c | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) (limited to 'commands.c') diff --git a/commands.c b/commands.c index 813610c..c70a009 100644 --- a/commands.c +++ b/commands.c @@ -23,6 +23,10 @@ Boston, MA 02111-1307, USA. */ #include "variable.h" #include "job.h" #include "commands.h" +#ifdef WINDOWS32 +#include +#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. */ -- cgit v1.2.3