diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index dc2e3b66e..088a90155 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,19 @@ +Sat Mar 10 16:52:12 2001 Christopher Faylor + + * shortcut.c (PATH_ALL_EXEC): Add parentheses to avoid a compiler + warning. + + * exceptions.cc (setup_handler): Clarify debugging message. + * sigproc.cc (proc_subproc): Remove PROC_CHILDSTOPPED test. It is + handled by normal PROC_CLEARWAIT case. + (wait_sig): Eliminate "dispatched" tracking. Remove __SIGCHILDSTOPPED + test. Decrement counter again before jumping out of + InterlockedDecrement loop so that subsequent InterlockedIncrement will + keep the counter at the correctly decremented value and also detect + when there are pending signals. + * sigproc.h: Remove __SIGCHILDSTOPPED element. + (procstuff): Remove PROC_CHILDSTOPPED element. + Sat Mar 10 15:22:44 2001 Christopher Faylor * syscalls.cc (_rename): Set errno to ENOENT when an old path doesn't diff --git a/winsup/cygwin/exceptions.cc b/winsup/cygwin/exceptions.cc index dc5b7fb72..6e1ae4591 100644 --- a/winsup/cygwin/exceptions.cc +++ b/winsup/cygwin/exceptions.cc @@ -601,7 +601,7 @@ sig_handle_tty_stop (int sig) if (my_parent_is_alive ()) { pinfo parent (myself->ppid); - sig_send (parent, __SIGCHILDSTOPPED); + sig_send (parent, SIGCHLD); } sigproc_printf ("process %d stopped by signal %d, myself->ppid_handle %p", myself->pid, sig, myself->ppid_handle); @@ -875,7 +875,7 @@ set_pending: LeaveCriticalSection (&th->lock); if (!hth) - sigproc_printf ("didn't suspend main thread, th %p", th); + sigproc_printf ("good. Didn't suspend main thread, th %p", th); else { res = ResumeThread (hth); diff --git a/winsup/cygwin/pinfo.h b/winsup/cygwin/pinfo.h index 2be262314..7f46850a6 100644 --- a/winsup/cygwin/pinfo.h +++ b/winsup/cygwin/pinfo.h @@ -1,6 +1,6 @@ /* pinfo.h: process table info - Copyright 2000 Cygnus Solutions. + Copyright 2000, 2001 Red Hat, Inc. This file is part of Cygwin. @@ -14,7 +14,7 @@ enum { __SIGFLUSH = -2, __SIGSTRACE = -1, - __SIGCHILDSTOPPED = 0, + __SIGUNUSED = 0, __SIGOFFSET = 3 }; diff --git a/winsup/cygwin/shortcut.c b/winsup/cygwin/shortcut.c index 6851f1274..b7ca86905 100644 --- a/winsup/cygwin/shortcut.c +++ b/winsup/cygwin/shortcut.c @@ -25,7 +25,7 @@ details. */ #define PATH_SYMLINK MOUNT_SYMLINK #define PATH_EXEC MOUNT_EXEC #define PATH_CYGWIN_EXEC MOUNT_CYGWIN_EXEC -#define PATH_ALL_EXEC PATH_CYGWIN_EXEC | PATH_EXEC +#define PATH_ALL_EXEC (PATH_CYGWIN_EXEC | PATH_EXEC) /* TODO: Ditto. */ static BOOL diff --git a/winsup/cygwin/sigproc.cc b/winsup/cygwin/sigproc.cc index f31660ee1..9eae394e8 100644 --- a/winsup/cygwin/sigproc.cc +++ b/winsup/cygwin/sigproc.cc @@ -309,15 +309,6 @@ proc_subproc (DWORD what, DWORD val) This will cause an eventual scan of waiters. */ break; - /* A child is in the stopped state. Scan wait() queue to see if anyone - * should be notified. (Called from wait_sig thread) - */ - case PROC_CHILDSTOPPED: - child = myself; // Just to avoid accidental NULL dereference - sigproc_printf ("Received stopped notification"); - clearing = 0; - goto scan_wait; - /* Handle a wait4() operation. Allocates an event for the calling * thread which is signaled when the appropriate pid exits or stops. * (usually called from the main thread) @@ -480,7 +471,7 @@ proc_terminate (void) void __stdcall sig_clear (int sig) { - (void) InterlockedExchange (myself->getsigtodo(sig), 0L); + (void) InterlockedExchange (myself->getsigtodo (sig), 0L); return; } @@ -703,7 +694,7 @@ sig_send (_pinfo *p, int sig, DWORD ebp) /* Increment the sigtodo array to signify which signal to assert. */ - (void) InterlockedIncrement (p->getsigtodo(sig)); + (void) InterlockedIncrement (p->getsigtodo (sig)); /* Notify the process that a signal has arrived. */ @@ -790,7 +781,7 @@ out: void __stdcall sig_set_pending (int sig) { - (void) InterlockedIncrement (myself->getsigtodo(sig)); + (void) InterlockedIncrement (myself->getsigtodo (sig)); return; } @@ -1134,7 +1125,6 @@ wait_sig (VOID *) } rc -= WAIT_OBJECT_0; - int dispatched = FALSE; sigproc_printf ("awake"); /* A sigcatch semaphore has been signaled. Scan the sigtodo * array looking for any unprocessed signals. @@ -1145,7 +1135,7 @@ wait_sig (VOID *) int dispatched_sigchld = 0; for (int sig = -__SIGOFFSET; sig < NSIG; sig++) { - while (InterlockedDecrement (myself->getsigtodo(sig)) >= 0) + while (InterlockedDecrement (myself->getsigtodo (sig)) >= 0) { if (sig == SIGCHLD) saw_sigchld = 1; @@ -1171,37 +1161,31 @@ wait_sig (VOID *) // proc_strace (); // Dump cached strace.prntf stuff. break; - /* Signalled from a child process that it has stopped */ - case __SIGCHILDSTOPPED: - sigproc_printf ("Received child stopped notification"); - dispatched |= sig_handle (SIGCHLD); - if (proc_subproc (PROC_CHILDSTOPPED, 0)) - dispatched |= 1; - break; - /* A normal UNIX signal */ default: sigproc_printf ("Got signal %d", sig); int wasdispatched = sig_handle (sig); - dispatched |= wasdispatched; if (sig == SIGCHLD && wasdispatched) dispatched_sigchld = 1; + /* Need to decrement again to offset increment below since + we really do want to decrement in this case. */ + InterlockedDecrement (myself->getsigtodo (sig)); goto nextsig; } } - /* Decremented too far. */ - if (InterlockedIncrement (myself->getsigtodo(sig)) > 0) - saw_pending_signals = 1; + nextsig: - continue; + /* Decremented too far. */ + if (InterlockedIncrement (myself->getsigtodo (sig)) > 0) + saw_pending_signals = 1; } - /* FIXME: The dispatched stuff probably isn't needed anymore. */ - if (dispatched >= 0 && pending_signals < 0 && !saw_pending_signals) + if (pending_signals < 0 && !saw_pending_signals) pending_signals = 0; - if (nzombies && saw_sigchld && !dispatched_sigchld) + if (saw_sigchld) proc_subproc (PROC_CLEARWAIT, 0); + /* Signal completion of signal handling depending on which semaphore * woke up the WaitForMultipleObjects above. */ @@ -1209,6 +1193,7 @@ wait_sig (VOID *) { case 0: SetEvent (sigcomplete_main); + sigproc_printf ("set main thread completion event"); break; case 1: ReleaseSemaphore (sigcomplete_nonmain, 1, NULL); @@ -1217,7 +1202,6 @@ wait_sig (VOID *) /* Signal from another process. No need to synchronize. */ break; } - sigproc_printf ("looping"); } diff --git a/winsup/cygwin/sigproc.h b/winsup/cygwin/sigproc.h index 0daa493f5..c67574d5b 100644 --- a/winsup/cygwin/sigproc.h +++ b/winsup/cygwin/sigproc.h @@ -17,11 +17,10 @@ details. */ enum procstuff { PROC_ADDCHILD = 1, // add a new subprocess to list - PROC_CHILDSTOPPED = 2, // a child stopped - PROC_CHILDTERMINATED = 3, // a child died - PROC_CLEARWAIT = 4, // clear all waits - signal arrived - PROC_WAIT = 5, // setup for wait() for subproc - PROC_NOTHING = 6 // nothing, really + PROC_CHILDTERMINATED = 2, // a child died + PROC_CLEARWAIT = 3, // clear all waits - signal arrived + PROC_WAIT = 4, // setup for wait() for subproc + PROC_NOTHING = 5 // nothing, really }; typedef struct struct_waitq