move signal handling before fork to avoid race with sigchild - scroll - scrollb… | |
git clone git://git.suckless.org/scroll | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
commit d40d23e29abf05092af051831c400a220c41ffb7 | |
parent aa683cbd8388e9bd3ae2c961a9fce47d519e2d2f | |
Author: Jan Klemkow <[email protected]> | |
Date: Tue, 14 Apr 2020 21:33:11 +0200 | |
move signal handling before fork to avoid race with sigchild | |
Diffstat: | |
M scroll.c | 10 +++++----- | |
1 file changed, 5 insertions(+), 5 deletions(-) | |
--- | |
diff --git a/scroll.c b/scroll.c | |
@@ -415,6 +415,11 @@ 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:"); | |
+ | |
child = forkpty(&mfd, NULL, &dfl, &ws); | |
if (child == -1) | |
die("forkpty:"); | |
@@ -441,11 +446,6 @@ main(int argc, char *argv[]) | |
die("pledge:"); | |
#endif | |
- if (signal(SIGCHLD, sigchld) == SIG_ERR) | |
- die("signal:"); | |
- if (signal(SIGWINCH, sigwinch) == SIG_ERR) | |
- die("signal:"); | |
- | |
struct termios new = dfl; | |
cfmakeraw(&new); | |
new.c_cc[VMIN ] = 1; /* return read if at least one byte in buf… |