* exceptions.cc (signal_exit): Move captive process termintation...

(_cygtls::interrupt_setup): ...into here.
(sigpacket::process): Simplify setting of handler when have_execed.
(_cygtls::interrupt_setup): Don't call proc_subproc when we've execed.
* globals.cc (exit_states): Delete unneeded ES_EXEC_EXIT.
* pinfo.cc (pinfo::exit): Change debugging output.  Call proc_terminate rather
than the now-obsolete sigproc_terminate.  Don't set exit_state to ES_EXEC_EXIT.
Set exit_state to ES_FINAL later.
* sigproc.cc (sigproc_terminate): Delete function.
(wait_sig): Don't call proc_subproc if have_execed.
* sigproc.h (sigproc_terminate): Delete declaration.
* sync.h (lock_process::lock_process): Don't set exit_state to
ES_PROCESS_LOCKED.
(lock_process::operator LONG): Define.
This commit is contained in:
Christopher Faylor 2013-01-14 06:03:59 +00:00
parent cdc1925e02
commit b712b4408a
7 changed files with 31 additions and 38 deletions

View File

@ -1,3 +1,20 @@
2013-01-14 Christopher Faylor <me.cygwin2013@cgf.cx>
* exceptions.cc (signal_exit): Move captive process termintation...
(_cygtls::interrupt_setup): ...into here.
(sigpacket::process): Simplify setting of handler when have_execed.
(_cygtls::interrupt_setup): Don't call proc_subproc when we've execed.
* globals.cc (exit_states): Delete unneeded ES_EXEC_EXIT.
* pinfo.cc (pinfo::exit): Change debugging output. Call proc_terminate
rather than the now-obsolete sigproc_terminate. Don't set exit_state
to ES_EXEC_EXIT. Set exit_state to ES_FINAL later.
* sigproc.cc (sigproc_terminate): Delete function.
(wait_sig): Don't call proc_subproc if have_execed.
* sigproc.h (sigproc_terminate): Delete declaration.
* sync.h (lock_process::lock_process): Don't set exit_state to
ES_PROCESS_LOCKED.
(lock_process::operator LONG): Define.
2013-01-11 Christopher Faylor <me.cygwin2013@cgf.cx> 2013-01-11 Christopher Faylor <me.cygwin2013@cgf.cx>
* DevNotes: Add entry cgf-000021. * DevNotes: Add entry cgf-000021.

View File

@ -764,7 +764,8 @@ _cygtls::interrupt_setup (siginfo_t& si, void *handler, struct sigaction& siga)
if (incyg) if (incyg)
SetEvent (get_signal_arrived (false)); SetEvent (get_signal_arrived (false));
proc_subproc (PROC_CLEARWAIT, 1); if (!have_execed)
proc_subproc (PROC_CLEARWAIT, 1);
sigproc_printf ("armed signal_arrived %p, signal %d", signal_arrived, si.si_signo); sigproc_printf ("armed signal_arrived %p, signal %d", signal_arrived, si.si_signo);
} }
@ -1089,12 +1090,6 @@ signal_exit (int sig, siginfo_t *si)
debug_printf ("exiting due to signal %d", sig); debug_printf ("exiting due to signal %d", sig);
exit_state = ES_SIGNAL_EXIT; exit_state = ES_SIGNAL_EXIT;
if (have_execed)
{
sigproc_printf ("terminating captive process");
TerminateProcess (ch_spawn, sigExeced = sig);
}
if (cygheap->rlim_core > 0UL) if (cygheap->rlim_core > 0UL)
switch (sig) switch (sig)
{ {
@ -1186,9 +1181,7 @@ sigpacket::process ()
sigproc_printf ("using tls %p", tls); sigproc_printf ("using tls %p", tls);
} }
void *handler = (void *) thissig.sa_handler; void *handler = have_execed ? NULL : (void *) thissig.sa_handler;
if (have_execed)
handler = NULL;
if (handler == SIG_IGN) if (handler == SIG_IGN)
{ {
@ -1271,6 +1264,11 @@ dispatch_sig:
if we hit an exception. */ if we hit an exception. */
_my_tls.signal_debugger (si.si_signo); _my_tls.signal_debugger (si.si_signo);
} }
if (have_execed)
{
sigproc_printf ("terminating captive process");
TerminateProcess (ch_spawn, sigExeced = si.si_signo);
}
/* Dispatch to the appropriate function. */ /* Dispatch to the appropriate function. */
sigproc_printf ("signal %d, signal handler %p", si.si_signo, handler); sigproc_printf ("signal %d, signal handler %p", si.si_signo, handler);
rc = setup_handler (handler, thissig, tls); rc = setup_handler (handler, thissig, tls);

View File

@ -43,7 +43,6 @@ enum exit_states
ES_THREADTERM, ES_THREADTERM,
ES_HUP_PGRP, ES_HUP_PGRP,
ES_HUP_SID, ES_HUP_SID,
ES_EXEC_EXIT,
ES_TTY_TERMINATE, ES_TTY_TERMINATE,
ES_FINAL ES_FINAL
}; };

View File

@ -175,18 +175,16 @@ pinfo::maybe_set_exit_code_from_windows ()
void void
pinfo::exit (DWORD n) pinfo::exit (DWORD n)
{ {
minimal_printf ("winpid %d, exit %d", GetCurrentProcessId (), n); debug_only_printf ("winpid %d, exit %d", GetCurrentProcessId (), n);
sigproc_terminate (ES_FINAL); proc_terminate ();
lock_process until_exit (true); lock_process until_exit (true);
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 else
{ maybe_set_exit_code_from_windows (); /* may block */
exit_state = ES_EXEC_EXIT; exit_state = ES_FINAL;
maybe_set_exit_code_from_windows ();
}
if (myself->ctty > 0 && !iscons_dev (myself->ctty)) if (myself->ctty > 0 && !iscons_dev (myself->ctty))
{ {

View File

@ -467,21 +467,6 @@ sigproc_init ()
new cygthread (wait_sig, cygself, "sig"); new cygthread (wait_sig, cygself, "sig");
} }
/* Called on process termination to terminate signal and process threads.
*/
void __stdcall
sigproc_terminate (exit_states es)
{
exit_states prior_exit_state = exit_state;
exit_state = es;
if (!cygwin_finished_initializing)
/* nothing to do */;
else if (prior_exit_state >= ES_FINAL)
sigproc_printf ("already performed");
else
proc_terminate (); // clean up process stuff
}
/* Exit the current thread very carefully. /* Exit the current thread very carefully.
See cgf-000017 in DevNotes for more details on why this is See cgf-000017 in DevNotes for more details on why this is
necessary. */ necessary. */
@ -1427,7 +1412,7 @@ wait_sig (VOID *)
} }
break; break;
} }
if (clearwait) if (clearwait && !have_execed)
proc_subproc (PROC_CLEARWAIT, 0); proc_subproc (PROC_CLEARWAIT, 0);
loop: loop:
if (pack.wakeup) if (pack.wakeup)

View File

@ -76,9 +76,6 @@ int __stdcall proc_subproc (DWORD, DWORD) __attribute__ ((regparm (2)));
class _pinfo; class _pinfo;
void __stdcall proc_terminate (); void __stdcall proc_terminate ();
void __stdcall sigproc_init (); void __stdcall sigproc_init ();
#ifdef __INSIDE_CYGWIN__
void __stdcall sigproc_terminate (enum exit_states);
#endif
bool __stdcall pid_exists (pid_t) __attribute__ ((regparm(1))); bool __stdcall pid_exists (pid_t) __attribute__ ((regparm(1)));
int __stdcall sig_send (_pinfo *, siginfo_t&, class _cygtls * = NULL) __attribute__ ((regparm (3))); int __stdcall sig_send (_pinfo *, siginfo_t&, class _cygtls * = NULL) __attribute__ ((regparm (3)));
int __stdcall sig_send (_pinfo *, int, class _cygtls * = NULL) __attribute__ ((regparm (3))); int __stdcall sig_send (_pinfo *, int, class _cygtls * = NULL) __attribute__ ((regparm (3)));

View File

@ -52,8 +52,6 @@ public:
{ {
locker.acquire (); locker.acquire ();
skip_unlock = exiting; skip_unlock = exiting;
if (exiting && exit_state < ES_PROCESS_LOCKED)
exit_state = ES_PROCESS_LOCKED;
} }
void release () void release ()
{ {
@ -65,6 +63,7 @@ public:
if (!skip_unlock) if (!skip_unlock)
release (); release ();
} }
operator LONG () const {return locker.visits; }
static void force_release (_cygtls *tid) {locker.release (tid);} static void force_release (_cygtls *tid) {locker.release (tid);}
friend class dtable; friend class dtable;
friend class fhandler_fifo; friend class fhandler_fifo;