+Sat Mar 10 16:52:12 2001 Christopher Faylor <cgf@cygnus.com>
+
+ * 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 <cgf@cygnus.com>
* syscalls.cc (_rename): Set errno to ENOENT when an old path doesn't
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);
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);
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)
void __stdcall
sig_clear (int sig)
{
- (void) InterlockedExchange (myself->getsigtodo(sig), 0L);
+ (void) InterlockedExchange (myself->getsigtodo (sig), 0L);
return;
}
/* 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.
*/
void __stdcall
sig_set_pending (int sig)
{
- (void) InterlockedIncrement (myself->getsigtodo(sig));
+ (void) InterlockedIncrement (myself->getsigtodo (sig));
return;
}
}
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.
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;
// 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;
}
}
+
+ nextsig:
/* Decremented too far. */
- if (InterlockedIncrement (myself->getsigtodo(sig)) > 0)
+ if (InterlockedIncrement (myself->getsigtodo (sig)) > 0)
saw_pending_signals = 1;
- nextsig:
- continue;
}
- /* 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.
*/
{
case 0:
SetEvent (sigcomplete_main);
+ sigproc_printf ("set main thread completion event");
break;
case 1:
ReleaseSemaphore (sigcomplete_nonmain, 1, NULL);
/* Signal from another process. No need to synchronize. */
break;
}
-
sigproc_printf ("looping");
}
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