diff options
author | sin <sin@2f30.org> | 2014-02-07 21:08:57 +0000 |
---|---|---|
committer | sin <sin@2f30.org> | 2014-02-07 21:08:57 +0000 |
commit | a4ddecaa6a99210f9bc6910c078a3a1cf1667c30 (patch) | |
tree | 0139f16c56a36e2dd722e7281146b49af7a99b53 | |
parent | 314b062efc5961bc3743df484a5cea9e7e62181f (diff) |
Don't nest too much
-rw-r--r-- | sinit.c | 24 |
1 files changed, 13 insertions, 11 deletions
@@ -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(); } } |