Introduction
Introduction Statistics Contact Development Disclaimer Help
Use sigwait() instead of signalfd() - sinit - suckless init
git clone git://git.suckless.org/sinit
Log
Files
Refs
README
LICENSE
---
commit 7fd10119bbb606d8e186e4e43bae3d1ab17e4184
parent 514b100944d0b61d8e8a295ab3cd534be4cfd344
Author: sin <[email protected]>
Date: Mon, 10 Feb 2014 20:04:58 +0000
Use sigwait() instead of signalfd()
Diffstat:
M sinit.c | 16 +++-------------
1 file changed, 3 insertions(+), 13 deletions(-)
---
diff --git a/sinit.c b/sinit.c
@@ -31,10 +31,8 @@ static sigset_t set;
int
main(void)
{
- struct signalfd_siginfo si;
- int fd;
+ int sig;
int i;
- ssize_t n;
if (getpid() != 1)
return EXIT_FAILURE;
@@ -45,20 +43,12 @@ main(void)
sigaddset(&set, sigmap[i].sig);
sigprocmask(SIG_BLOCK, &set, NULL);
- fd = signalfd(-1, &set, SFD_CLOEXEC);
- if (fd < 0)
- eprintf("sinit: signalfd:");
-
spawn(rcinitcmd);
while (1) {
- n = read(fd, &si, sizeof(si));
- if (n < 0)
- eprintf("sinit: read:");
- if (n != sizeof(si))
- continue;
+ sigwait(&set, &sig);
for (i = 0; i < LEN(sigmap); i++)
- if (sigmap[i].sig == si.ssi_signo)
+ if (sigmap[i].sig == sig)
sigmap[i].handler();
}
You are viewing proxied material from suckless.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.