Semi-reversion of always-exit-from-sigthread change of 2005-09-15.
* exceptions.cc (sigpacket::process): Eliminate return after call to reinstated noreturn function. (signal_exit): Allow function to exit when a captive process has been terminated. * pinfo.cc (pinfo::exit): Enter exit_lock here. Once again exit here under control of exit_lock. * sigproc.cc (sig_send): Don't wait for completion if process is exiting. Remove special __SIGEXIT accommodations. (wait_sig): Just exit the thread when a __SIGEXIT has been detected. Don't exit the process.
This commit is contained in:
parent
1b19d74296
commit
5e477e9a9b
|
@ -1,3 +1,17 @@
|
||||||
|
2005-09-23 Christopher Faylor <cgf@timesys.com>
|
||||||
|
|
||||||
|
Semi-reversion of always-exit-from-sigthread change of 2005-09-15.
|
||||||
|
* exceptions.cc (sigpacket::process): Eliminate return after call to
|
||||||
|
reinstated noreturn function.
|
||||||
|
(signal_exit): Allow function to exit when a captive process has been
|
||||||
|
terminated.
|
||||||
|
* pinfo.cc (pinfo::exit): Enter exit_lock here. Once again exit here
|
||||||
|
under control of exit_lock.
|
||||||
|
* sigproc.cc (sig_send): Don't wait for completion if process is exiting.
|
||||||
|
Remove special __SIGEXIT accommodations.
|
||||||
|
(wait_sig): Just exit the thread when a __SIGEXIT has been detected.
|
||||||
|
Don't exit the process.
|
||||||
|
|
||||||
2005-09-23 Christopher Faylor <cgf@timesys.com>
|
2005-09-23 Christopher Faylor <cgf@timesys.com>
|
||||||
|
|
||||||
* net.cc (cygwin_gethostbyname): Remove debugging cruft.
|
* net.cc (cygwin_gethostbyname): Remove debugging cruft.
|
||||||
|
|
|
@ -40,7 +40,7 @@ extern NO_COPY DWORD dwExeced;
|
||||||
int NO_COPY sigExeced;
|
int NO_COPY sigExeced;
|
||||||
|
|
||||||
static BOOL WINAPI ctrl_c_handler (DWORD);
|
static BOOL WINAPI ctrl_c_handler (DWORD);
|
||||||
static void signal_exit (int);
|
static void signal_exit (int) __attribute__ ((noreturn));
|
||||||
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,9 +1160,7 @@ exit_sig:
|
||||||
si.si_signo |= 0x80;
|
si.si_signo |= 0x80;
|
||||||
}
|
}
|
||||||
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 */
|
|
||||||
return rc;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CRITICAL_SECTION NO_COPY exit_lock;
|
CRITICAL_SECTION NO_COPY exit_lock;
|
||||||
|
@ -1177,11 +1175,10 @@ signal_exit (int rc)
|
||||||
{
|
{
|
||||||
sigproc_printf ("terminating captive process");
|
sigproc_printf ("terminating captive process");
|
||||||
TerminateProcess (hExeced, sigExeced = rc);
|
TerminateProcess (hExeced, sigExeced = rc);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
EnterCriticalSection (&exit_lock);
|
EnterCriticalSection (&exit_lock);
|
||||||
if (exit_already++)
|
if (hExeced || exit_state)
|
||||||
myself.exit (rc);
|
myself.exit (rc);
|
||||||
|
|
||||||
/* We'd like to stop the main thread from executing but when we do that it
|
/* We'd like to stop the main thread from executing but when we do that it
|
||||||
|
|
|
@ -141,6 +141,7 @@ extern "C" int WINAPI
|
||||||
dll_entry (HANDLE h, DWORD reason, void *static_load)
|
dll_entry (HANDLE h, DWORD reason, void *static_load)
|
||||||
{
|
{
|
||||||
BOOL is_wow64_proc = FALSE;
|
BOOL is_wow64_proc = FALSE;
|
||||||
|
// _STRACE_ON;
|
||||||
|
|
||||||
switch (reason)
|
switch (reason)
|
||||||
{
|
{
|
||||||
|
|
|
@ -151,31 +151,19 @@ pinfo::exit (DWORD n)
|
||||||
}
|
}
|
||||||
|
|
||||||
sigproc_terminate (ES_FINAL);
|
sigproc_terminate (ES_FINAL);
|
||||||
|
zap_cwd ();
|
||||||
|
|
||||||
/* 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 that, though. */
|
parent here. I hated to add a mutex just for that, though. */
|
||||||
struct rusage r;
|
struct rusage r;
|
||||||
fill_rusage (&r, hMainProc);
|
fill_rusage (&r, hMainProc);
|
||||||
add_rusage (&self->rusage_self, &r);
|
add_rusage (&self->rusage_self, &r);
|
||||||
|
|
||||||
if (n != EXITCODE_NOSET)
|
|
||||||
{
|
|
||||||
zap_cwd ();
|
|
||||||
self->alert_parent (0); /* Shave a little time by telling our
|
|
||||||
parent that we have now exited. */
|
|
||||||
}
|
|
||||||
int exitcode = self->exitcode & 0xffff;
|
int exitcode = self->exitcode & 0xffff;
|
||||||
if (!self->cygstarted)
|
if (!self->cygstarted)
|
||||||
exitcode >>= 8;
|
exitcode >>= 8;
|
||||||
|
release ();
|
||||||
_my_tls.stacklock = 0;
|
sigproc_printf ("Calling ExitProcess n %p, exitcode %p", n, exitcode);
|
||||||
_my_tls.stackptr = _my_tls.stack;
|
ExitProcess (exitcode);
|
||||||
sigproc_printf ("Calling ExitThread hProcess %p, n %p, exitcode %p",
|
|
||||||
hProcess, n, exitcode);
|
|
||||||
if (&_my_tls == _sig_tls)
|
|
||||||
ExitProcess (exitcode);
|
|
||||||
else
|
|
||||||
ExitThread (exitcode);
|
|
||||||
}
|
}
|
||||||
# undef self
|
# undef self
|
||||||
|
|
||||||
|
|
|
@ -553,7 +553,7 @@ sig_send (_pinfo *p, siginfo_t& si, _cygtls *tls)
|
||||||
}
|
}
|
||||||
if (wait_sig_inited)
|
if (wait_sig_inited)
|
||||||
wait_for_sigthread ();
|
wait_for_sigthread ();
|
||||||
wait_for_completion = p != myself_nowait && _my_tls.isinitialized ();
|
wait_for_completion = p != myself_nowait && _my_tls.isinitialized () && !exit_state;
|
||||||
p = myself;
|
p = myself;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -621,15 +621,7 @@ sig_send (_pinfo *p, siginfo_t& si, _cygtls *tls)
|
||||||
pack.si.si_uid = myself->uid;
|
pack.si.si_uid = myself->uid;
|
||||||
pack.pid = myself->pid;
|
pack.pid = myself->pid;
|
||||||
pack.tls = (_cygtls *) tls;
|
pack.tls = (_cygtls *) tls;
|
||||||
if (si.si_signo == __SIGEXIT)
|
if (wait_for_completion)
|
||||||
{
|
|
||||||
if (&_my_tls == _main_tls)
|
|
||||||
pack.thread_handle = hMainThread;
|
|
||||||
else
|
|
||||||
DuplicateHandle (hMainProc, GetCurrentThread (), hMainProc, &pack.thread_handle, 0,
|
|
||||||
FALSE, DUPLICATE_SAME_ACCESS);
|
|
||||||
}
|
|
||||||
else if (wait_for_completion)
|
|
||||||
{
|
{
|
||||||
pack.wakeup = CreateEvent (&sec_none_nih, FALSE, FALSE, NULL);
|
pack.wakeup = CreateEvent (&sec_none_nih, FALSE, FALSE, NULL);
|
||||||
sigproc_printf ("wakeup %p", pack.wakeup);
|
sigproc_printf ("wakeup %p", pack.wakeup);
|
||||||
|
@ -1122,29 +1114,6 @@ wait_sig (VOID *self)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
my_sendsig = NULL;
|
sigproc_printf ("signal thread exiting");
|
||||||
HANDLE& h = pack.thread_handle;
|
ExitThread (0);
|
||||||
if (!h)
|
|
||||||
api_fatal ("no thread handle set on exit");
|
|
||||||
DWORD res = WaitForSingleObject (h, INFINITE);
|
|
||||||
|
|
||||||
DWORD exitcode = 1;
|
|
||||||
|
|
||||||
myself.release ();
|
|
||||||
if (res == WAIT_OBJECT_0)
|
|
||||||
{
|
|
||||||
GetExitCodeThread (h, &exitcode);
|
|
||||||
#ifdef DEBUGGING
|
|
||||||
hMainThread = INVALID_HANDLE_VALUE;
|
|
||||||
#endif
|
|
||||||
} else {
|
|
||||||
#ifdef DEBUGGING
|
|
||||||
console_printf ("wait for main thread %p returned %d", h, res);
|
|
||||||
#else
|
|
||||||
debug_printf ("wait for main thread %p returned %d", h, res);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
sigproc_printf ("calling ExitProcess, exitcode %p", exitcode);
|
|
||||||
ExitProcess (exitcode);
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue