Introduction
Introduction Statistics Contact Development Disclaimer Help
handle child exit via POLLHUP instead of sigchld - scroll - scrollbackbuffer pr…
git clone git://git.suckless.org/scroll
Log
Files
Refs
README
LICENSE
---
commit 97b90414891e957c95caffe078c69b18aa38e659
parent d10c029b182fef1af4c6ec2713f9a8a3a5245edb
Author: Jan Klemkow <[email protected]>
Date: Fri, 17 Apr 2020 21:46:55 +0200
handle child exit via POLLHUP instead of sigchld
this fix a racecondition which leads to wrong return code.
Diffstat:
M scroll.c | 21 ++-------------------
1 file changed, 2 insertions(+), 19 deletions(-)
---
diff --git a/scroll.c b/scroll.c
@@ -90,19 +90,6 @@ die(const char *fmt, ...)
}
void
-sigchld(int sig)
-{
- pid_t pid;
- int status;
-
- assert(sig == SIGCHLD);
-
- while ((pid = waitpid(-1, &status, WNOHANG)) > 0)
- if (pid == child)
- exit(WEXITSTATUS(status));
-}
-
-void
sigwinch(int sig)
{
assert(sig == SIGWINCH);
@@ -421,8 +408,6 @@ main(int argc, char *argv[])
if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &ws) < 0)
die("ioctl:");
- if (signal(SIGCHLD, sigchld) == SIG_ERR)
- die("signal:");
if (signal(SIGWINCH, sigwinch) == SIG_ERR)
die("signal:");
@@ -553,11 +538,9 @@ main(int argc, char *argv[])
if (close(mfd) == -1)
die("close:");
- pid_t pid;
int status;
- while ((pid = waitpid(-1, &status, WNOHANG)) > 0)
- if (pid != child)
- continue;
+ if (waitpid(child, &status, 0) == -1)
+ die("waitpid:");
return WEXITSTATUS(status);
}
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.