* dcrt0.cc (do_exit): Only call sigproc_terminate from one location --

pinfo::exit.
* pinfo.cc (pinfo::exit): Move sigproc_terminate later so that signals can be
processed while waiting for hExeced child.
(pinfo::maybe_set_exit_code_from_windows): Set exit code from sigExeced if it
is non-zero.  Set exit_state to ES_EXEC_EXIT prior to waiting for captive
process exit code.
* exceptions.cc (sigExeced): New global variable.
(signal_exit): Remove noreturn attribute from declaration.
(signal_exit): Just terminate captive process and return if hExeced on the
theory that the exit will be subsequently handled in the main thread.
* sigproc.cc (sigproc_terminate): Eliminate test for ES_SIGPROCTERMINATE and
use ES_FINAL instead.
(sig_send): Use no_signals_available instead of duplicate test.
* winsup.h (ES_EXEC_EXIT): New enum.
(ES_SIGPROCTERMINATE): Delete.
This commit is contained in:
Christopher Faylor
2005-09-20 02:06:57 +00:00
parent cddfc170fd
commit c529909f45
6 changed files with 45 additions and 21 deletions

View File

@ -36,10 +36,11 @@ static int handle_exceptions (EXCEPTION_RECORD *, void *, CONTEXT *, void *);
extern void sigdelayed ();
};
extern DWORD dwExeced;
extern NO_COPY DWORD dwExeced;
int NO_COPY sigExeced;
static BOOL WINAPI ctrl_c_handler (DWORD);
static void signal_exit (int) __attribute__ ((noreturn));
static void signal_exit (int);
char windows_system_directory[1024];
static size_t windows_system_directory_length;
@ -1160,7 +1161,7 @@ exit_sig:
}
sigproc_printf ("signal %d, about to call do_exit", si.si_signo);
signal_exit (si.si_signo);
/* Never returns */
/* May not return */
}
CRITICAL_SECTION NO_COPY exit_lock;
@ -1171,6 +1172,13 @@ CRITICAL_SECTION NO_COPY exit_lock;
static void
signal_exit (int rc)
{
if (hExeced)
{
sigproc_printf ("terminating captive process");
TerminateProcess (hExeced, sigExeced = rc);
return;
}
EnterCriticalSection (&exit_lock);
if (exit_already++)
myself.exit (rc);
@ -1184,12 +1192,6 @@ signal_exit (int rc)
user_data->resourcelocks->Delete ();
user_data->resourcelocks->Init ();
if (hExeced)
{
sigproc_printf ("terminating captive process");
TerminateProcess (hExeced, rc);
}
sigproc_printf ("about to call do_exit (%x)", rc);
SetEvent (signal_arrived);
do_exit (rc);