(empth_init_signals): Don't catch SIGINT and SIGTERM.

(empth_wait_for_shutdown): New.
(main): Use it to wait for shutdown signal, then shut down.  Closes
#770492.
(empth_exit): Remove the weird special case for main thread.

Implement empth_wait_for_shutdown() for EMPTH_LWP:
[EMPTH_LWP] (lwpInitSigWait, lwpSigWait, lwpSigWakeup): New.
Declaration of lwpSigWait was accidentally committed in the previous
revision of lwp.h.
[EMPTH_LWP] (lwpInitSystem): New parameter waitset, pass it on to
lwpInitSigWait().
[EMPTH_LWP] (lwpReschedule): Call lwpSigWakeup().
[EMPTH_LWP] (empth_init): Declare signals needed by
empth_wait_for_shutdown().
(empth_wait_for_shutdown): Implement on top of lwpSigWait().

Implement empth_wait_for_shutdown() for EMPTH_POSIX:
[EMPTH_POSIX] (empth_init): Block signals, so that
empth_wait_for_shutdown() can use sigwait() safely.
(empth_wait_for_shutdown): Implement on top of sigwait().

Implement empth_wait_for_shutdown() for EMPTH_W32:
(empth_wait_for_shutdown): Implement on top of loc_BlockMainThread().
This commit is contained in:
Markus Armbruster 2006-06-07 21:01:16 +00:00
parent f51769659c
commit 7183516d91
10 changed files with 251 additions and 71 deletions

View file

@ -76,6 +76,8 @@ lwpReschedule(void)
lwpStackCheck(LwpCurrent);
}
lwpSigWakeup();
/* destroy dead threads */
lwpStatus(LwpCurrent, "Cleaning dead queue");
while (NULL != (nextp = lwpGetFirst(&LwpDeadQ))) {
@ -285,7 +287,7 @@ lwpSetPriority(int new)
* initialise the coroutine structures
*/
struct lwpProc *
lwpInitSystem(int pri, char **ctxptr, int flags)
lwpInitSystem(int pri, char **ctxptr, int flags, sigset_t *waitset)
{
struct lwpQueue *q;
int i, *stack, marker;
@ -313,6 +315,7 @@ lwpInitSystem(int pri, char **ctxptr, int flags)
for (i = LWP_MAX_PRIO, q = LwpSchedQ; i--; q++)
q->head = q->tail = 0;
LwpDeadQ.head = LwpDeadQ.tail = 0;
lwpInitSigWait(waitset);
/* must be lower in priority than us for this to work right */
sel = lwpCreate(0, lwpSelect, 16384, flags, "EventHandler",
"Select (main loop) Event Handler", 0, 0, 0);