mirror of
git://sourceware.org/git/newlib-cygwin.git
synced 2025-02-21 16:26:12 +08:00
* 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:
parent
cddfc170fd
commit
c529909f45
@ -1,3 +1,23 @@
|
|||||||
|
2005-09-19 Christopher Faylor <cgf@timesys.com>
|
||||||
|
|
||||||
|
* 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.
|
||||||
|
|
||||||
2005-09-19 Christopher Faylor <cgf@timesys.com>
|
2005-09-19 Christopher Faylor <cgf@timesys.com>
|
||||||
|
|
||||||
* sigproc.cc (talktome): Take siginfo_t argument. Don't scan all pids
|
* sigproc.cc (talktome): Take siginfo_t argument. Don't scan all pids
|
||||||
|
@ -1091,9 +1091,6 @@ do_exit (int status)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (exit_state < ES_SIGPROCTERMINATE)
|
|
||||||
sigproc_terminate (ES_SIGPROCTERMINATE); // sets exit_state directly
|
|
||||||
|
|
||||||
if (exit_state < ES_TITLE)
|
if (exit_state < ES_TITLE)
|
||||||
{
|
{
|
||||||
exit_state = ES_TITLE;
|
exit_state = ES_TITLE;
|
||||||
|
@ -36,10 +36,11 @@ static int handle_exceptions (EXCEPTION_RECORD *, void *, CONTEXT *, void *);
|
|||||||
extern void sigdelayed ();
|
extern void sigdelayed ();
|
||||||
};
|
};
|
||||||
|
|
||||||
extern DWORD dwExeced;
|
extern NO_COPY DWORD dwExeced;
|
||||||
|
int NO_COPY sigExeced;
|
||||||
|
|
||||||
static BOOL WINAPI ctrl_c_handler (DWORD);
|
static BOOL WINAPI ctrl_c_handler (DWORD);
|
||||||
static void signal_exit (int) __attribute__ ((noreturn));
|
static void signal_exit (int);
|
||||||
char windows_system_directory[1024];
|
char windows_system_directory[1024];
|
||||||
static size_t windows_system_directory_length;
|
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);
|
sigproc_printf ("signal %d, about to call do_exit", si.si_signo);
|
||||||
signal_exit (si.si_signo);
|
signal_exit (si.si_signo);
|
||||||
/* Never returns */
|
/* May not return */
|
||||||
}
|
}
|
||||||
|
|
||||||
CRITICAL_SECTION NO_COPY exit_lock;
|
CRITICAL_SECTION NO_COPY exit_lock;
|
||||||
@ -1171,6 +1172,13 @@ CRITICAL_SECTION NO_COPY exit_lock;
|
|||||||
static void
|
static void
|
||||||
signal_exit (int rc)
|
signal_exit (int rc)
|
||||||
{
|
{
|
||||||
|
if (hExeced)
|
||||||
|
{
|
||||||
|
sigproc_printf ("terminating captive process");
|
||||||
|
TerminateProcess (hExeced, sigExeced = rc);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
EnterCriticalSection (&exit_lock);
|
EnterCriticalSection (&exit_lock);
|
||||||
if (exit_already++)
|
if (exit_already++)
|
||||||
myself.exit (rc);
|
myself.exit (rc);
|
||||||
@ -1184,12 +1192,6 @@ signal_exit (int rc)
|
|||||||
user_data->resourcelocks->Delete ();
|
user_data->resourcelocks->Delete ();
|
||||||
user_data->resourcelocks->Init ();
|
user_data->resourcelocks->Init ();
|
||||||
|
|
||||||
if (hExeced)
|
|
||||||
{
|
|
||||||
sigproc_printf ("terminating captive process");
|
|
||||||
TerminateProcess (hExeced, rc);
|
|
||||||
}
|
|
||||||
|
|
||||||
sigproc_printf ("about to call do_exit (%x)", rc);
|
sigproc_printf ("about to call do_exit (%x)", rc);
|
||||||
SetEvent (signal_arrived);
|
SetEvent (signal_arrived);
|
||||||
do_exit (rc);
|
do_exit (rc);
|
||||||
|
@ -111,13 +111,15 @@ pinfo::maybe_set_exit_code_from_windows ()
|
|||||||
{
|
{
|
||||||
DWORD x = 0xdeadbeef;
|
DWORD x = 0xdeadbeef;
|
||||||
DWORD oexitcode = self->exitcode;
|
DWORD oexitcode = self->exitcode;
|
||||||
|
extern int sigExeced;
|
||||||
|
|
||||||
if (hProcess && !(self->exitcode & EXITCODE_SET))
|
if (hProcess && !(self->exitcode & EXITCODE_SET))
|
||||||
{
|
{
|
||||||
WaitForSingleObject (hProcess, INFINITE); // just to be safe, in case
|
WaitForSingleObject (hProcess, INFINITE); // just to be safe, in case
|
||||||
// process hasn't quite exited
|
// process hasn't quite exited
|
||||||
// after closing pipe
|
// after closing pipe
|
||||||
GetExitCodeProcess (hProcess, &x);
|
GetExitCodeProcess (hProcess, &x);
|
||||||
self->exitcode = EXITCODE_SET | (x & 0xff) << 8;
|
self->exitcode = EXITCODE_SET | (sigExeced ?: (x & 0xff) << 8);
|
||||||
}
|
}
|
||||||
sigproc_printf ("pid %d, exit value - old %p, windows %p, cygwin %p",
|
sigproc_printf ("pid %d, exit value - old %p, windows %p, cygwin %p",
|
||||||
self->pid, oexitcode, x, self->exitcode);
|
self->pid, oexitcode, x, self->exitcode);
|
||||||
@ -136,11 +138,16 @@ pinfo::zap_cwd ()
|
|||||||
void
|
void
|
||||||
pinfo::exit (DWORD n)
|
pinfo::exit (DWORD n)
|
||||||
{
|
{
|
||||||
sigproc_terminate (ES_FINAL);
|
|
||||||
|
|
||||||
cygthread::terminate ();
|
cygthread::terminate ();
|
||||||
if (n != EXITCODE_NOSET)
|
if (n != EXITCODE_NOSET)
|
||||||
self->exitcode = EXITCODE_SET | n;/* We're really exiting. Record the UNIX exit code. */
|
self->exitcode = EXITCODE_SET | n;/* We're really exiting. Record the UNIX exit code. */
|
||||||
|
else
|
||||||
|
{
|
||||||
|
exit_state = ES_EXEC_EXIT;
|
||||||
|
maybe_set_exit_code_from_windows ();
|
||||||
|
}
|
||||||
|
|
||||||
|
sigproc_terminate (ES_FINAL);
|
||||||
|
|
||||||
/* FIXME: There is a potential race between an execed process and its
|
/* FIXME: There is a potential race between an execed process and its
|
||||||
parent here. I hated to add a mutex just for this, though. */
|
parent here. I hated to add a mutex just for this, though. */
|
||||||
@ -148,8 +155,6 @@ pinfo::exit (DWORD n)
|
|||||||
fill_rusage (&r, hMainProc);
|
fill_rusage (&r, hMainProc);
|
||||||
add_rusage (&self->rusage_self, &r);
|
add_rusage (&self->rusage_self, &r);
|
||||||
|
|
||||||
maybe_set_exit_code_from_windows ();
|
|
||||||
|
|
||||||
if (n != EXITCODE_NOSET)
|
if (n != EXITCODE_NOSET)
|
||||||
{
|
{
|
||||||
zap_cwd ();
|
zap_cwd ();
|
||||||
|
@ -492,7 +492,7 @@ sigproc_terminate (exit_states es)
|
|||||||
{
|
{
|
||||||
exit_states prior_exit_state = exit_state;
|
exit_states prior_exit_state = exit_state;
|
||||||
exit_state = es;
|
exit_state = es;
|
||||||
if (prior_exit_state > ES_SIGPROCTERMINATE)
|
if (prior_exit_state >= ES_FINAL)
|
||||||
sigproc_printf ("already performed");
|
sigproc_printf ("already performed");
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -541,7 +541,7 @@ sig_send (_pinfo *p, siginfo_t& si, _cygtls *tls)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!my_sendsig || (si.si_signo != __SIGEXIT && myself->exitcode & EXITCODE_SET) || &_my_tls == _sig_tls)
|
if (no_signals_available (si.si_signo != __SIGEXIT))
|
||||||
{
|
{
|
||||||
sigproc_printf ("my_sendsig %p, myself->sendsig %p, exit_state %d",
|
sigproc_printf ("my_sendsig %p, myself->sendsig %p, exit_state %d",
|
||||||
my_sendsig, myself->sendsig, exit_state);
|
my_sendsig, myself->sendsig, exit_state);
|
||||||
@ -638,7 +638,7 @@ sig_send (_pinfo *p, siginfo_t& si, _cygtls *tls)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (no_signals_available (si.si_signo != __SIGEXIT))
|
if (no_signals_available (true))
|
||||||
sigproc_printf ("I'm going away now");
|
sigproc_printf ("I'm going away now");
|
||||||
else if (!p->exec_sendsig)
|
else if (!p->exec_sendsig)
|
||||||
system_printf ("error sending signal %d to pid %d, pipe handle %p, %E",
|
system_printf ("error sending signal %d to pid %d, pipe handle %p, %E",
|
||||||
|
@ -195,7 +195,7 @@ enum exit_states
|
|||||||
ES_CLOSEALL,
|
ES_CLOSEALL,
|
||||||
ES_HUP_PGRP,
|
ES_HUP_PGRP,
|
||||||
ES_HUP_SID,
|
ES_HUP_SID,
|
||||||
ES_SIGPROCTERMINATE,
|
ES_EXEC_EXIT,
|
||||||
ES_TITLE,
|
ES_TITLE,
|
||||||
ES_TTY_TERMINATE,
|
ES_TTY_TERMINATE,
|
||||||
ES_FINAL
|
ES_FINAL
|
||||||
|
Loading…
x
Reference in New Issue
Block a user