X-Git-Url: http://git.pond.sub.org/?p=empserver;a=blobdiff_plain;f=src%2Flib%2Flwp%2Fsig.c;h=04fb9f97741dba4d645c893673d3a8aa4e029afe;hp=60e3b375958bee7f71121535d558b5c5d7ea09c8;hb=aae823507c366d5a52ebef5627d667faeb444d89;hpb=73e25ff21eb3d172961db1cad4bd370f17103c23 diff --git a/src/lib/lwp/sig.c b/src/lib/lwp/sig.c index 60e3b3759..04fb9f977 100644 --- a/src/lib/lwp/sig.c +++ b/src/lib/lwp/sig.c @@ -1,11 +1,11 @@ /* * Empire - A multi-player, client/server Internet based war game. - * Copyright (C) 1994-2010, Dave Pare, Jeff Bailey, Thomas Ruschak, - * Ken Stevens, Steve McClure + * Copyright (C) 1994-2020, Dave Pare, Jeff Bailey, Thomas Ruschak, + * Ken Stevens, Steve McClure, Markus Armbruster * - * This program is free software; you can redistribute it and/or modify + * Empire is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, @@ -14,8 +14,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * along with this program. If not, see . * * --- * @@ -28,7 +27,7 @@ * sig.c: Wait for signals * * Known contributors to this file: - * Markus Armbruster, 2006-2007 + * Markus Armbruster, 2006-2020 */ #include @@ -40,13 +39,13 @@ #include "lwpint.h" /* - * Signals catched so far. + * Signals caught so far. * Access only with signals blocked! */ -static sigset_t LwpSigCatched; +static sigset_t LwpSigCaught; /* - * LwpSigCatched changed since last + * LwpSigCaught changed since last */ static sig_atomic_t LwpSigCheck; @@ -56,7 +55,7 @@ static struct lwpProc *LwpSigWaiter; static void lwpCatchAwaitedSig(int); /* - * Initialize waiting for signals in SET. + * Initialize waiting for signals in @set. */ void lwpInitSigWait(sigset_t *set) @@ -64,14 +63,13 @@ lwpInitSigWait(sigset_t *set) struct sigaction act; int i; - sigemptyset(&LwpSigCatched); + sigemptyset(&LwpSigCaught); act.sa_flags = 0; act.sa_mask = *set; - sigemptyset(&act.sa_mask); act.sa_handler = lwpCatchAwaitedSig; for (i = 0; i < NSIG; i++) { - if (sigismember(set, i)) + if (sigismember(set, i) > 0) sigaction(i, &act, NULL); } } @@ -79,13 +77,13 @@ lwpInitSigWait(sigset_t *set) static void lwpCatchAwaitedSig(int sig) { - sigaddset(&LwpSigCatched, sig); + sigaddset(&LwpSigCaught, sig); LwpSigCheck = 1; } /* - * Test whether a signal from SET has been catched. - * If yes, delete that signal from the set of catched signals, and + * Test whether a signal from @set has been caught. + * If yes, delete that signal from the set of caught signals, and * return its number. * Else return 0. */ @@ -97,9 +95,9 @@ lwpGetSig(sigset_t *set) sigprocmask(SIG_BLOCK, set, &save); for (i = NSIG - 1; i > 0; i--) { - if (sigismember(set, i) && sigismember(&LwpSigCatched, i)) { + if (sigismember(set, i) > 0 && sigismember(&LwpSigCaught, i) > 0) { lwpStatus(LwpCurrent, "Got awaited signal %d", i); - sigdelset(&LwpSigCatched, i); + sigdelset(&LwpSigCaught, i); break; } } @@ -108,8 +106,8 @@ lwpGetSig(sigset_t *set) } /* - * Wait until a signal from SET arrives. - * Assign its number to *SIG and return 0. + * Wait until a signal from @set arrives. + * Assign its number to *@sig and return 0. * If another thread is already waiting for signals, return EBUSY * without waiting. */ @@ -118,7 +116,7 @@ lwpSigWait(sigset_t *set, int *sig) { int res; - if (CANT_HAPPEN(LwpSigWaiter)) + if (LwpSigWaiter) return EBUSY; for (;;) { LwpSigCheck = 0;