scroll

scrollbackbuffer program for st
git clone git://git.suckless.org/scroll
Log | Files | Refs | README

commit a0cb60891a7420ab2256f238498317569879d4d3
parent c4153df6202b944f947b018d6e461170a3a1168e
Author: Jan Klemkow <j.klemkow@wemelug.de>
Date:   Tue, 14 Apr 2020 22:14:09 +0200

passthrough EOF from Terminal to child, plus exit handling

Diffstat:
Mscroll.c | 14++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/scroll.c b/scroll.c @@ -477,8 +477,10 @@ main(int argc, char *argv[]) if (pfd[0].revents & POLLIN) { ssize_t n = read(STDIN_FILENO, input, sizeof(input)-1); - if (n <= 0 && errno != EINTR) + if (n == -1 && errno != EINTR) die("read:"); + if (n == 0) + break; input[n] = '\0'; @@ -538,5 +540,13 @@ main(int argc, char *argv[]) } } - return EXIT_SUCCESS; + if (close(mfd) == -1) + die("close:"); + + int status; + while ((pid = waitpid(-1, &status, WNOHANG)) > 0) + if (pid != child) + continue; + + return WEXITSTATUS(status); }