sinit

suckless init
git clone git://git.2f30.org/sinit.git
Log | Files | Refs | README | LICENSE

commit a4ddecaa6a99210f9bc6910c078a3a1cf1667c30
parent 314b062efc5961bc3743df484a5cea9e7e62181f
Author: sin <sin@2f30.org>
Date:   Fri Feb  7 21:08:57 +0000

Don't nest too much

Diffstat:
sinit.c | 24+++++++++++++-----------
1 file changed, 13 insertions(+), 11 deletions(-)
diff --git a/sinit.c b/sinit.c @@ -56,9 +56,11 @@ main(void) if (sigemptyset(&sigset) < 0) eprintf("sinit: sigemptyset:"); + for (i = 0; i < LEN(dispatchsig); i++) if (sigaddset(&sigset, dispatchsig[i].sig) < 0) eprintf("sinit: sigaddset:"); + if (sigprocmask(SIG_BLOCK, &sigset, NULL) < 0) eprintf("sinit: sigprocmask:"); @@ -74,17 +76,17 @@ main(void) ret = select(sigfd + 1, &rfds, NULL, NULL, NULL); if (ret < 0) eprintf("sinit: select:"); - if (ret > 0) { - if (FD_ISSET(sigfd, &rfds)) { - n = read(sigfd, &siginfo, sizeof(siginfo)); - if (n < 0) - eprintf("sinit: read:"); - if (n != sizeof(siginfo)) - continue; - for (i = 0; i < LEN(dispatchsig); i++) - if (dispatchsig[i].sig == siginfo.ssi_signo) - dispatchsig[i].func(); - } + if (ret == 0) + continue; + if (FD_ISSET(sigfd, &rfds)) { + n = read(sigfd, &siginfo, sizeof(siginfo)); + if (n < 0) + eprintf("sinit: read:"); + if (n != sizeof(siginfo)) + continue; + for (i = 0; i < LEN(dispatchsig); i++) + if (dispatchsig[i].sig == siginfo.ssi_signo) + dispatchsig[i].func(); } }