From 570b878f6bbdb81872f3df4ef9e5e7ab1c66cf1a Mon Sep 17 00:00:00 2001 From: Curtis McEnroe Date: Fri, 14 Jul 2017 23:50:29 -0400 Subject: Detect death of child --- curtis/.bin/dtch.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'curtis') diff --git a/curtis/.bin/dtch.c b/curtis/.bin/dtch.c index 071116b4..dc3b5719 100755 --- a/curtis/.bin/dtch.c +++ b/curtis/.bin/dtch.c @@ -10,6 +10,7 @@ exit #include #include #include +#include #include #include #include @@ -150,8 +151,6 @@ static int dtch(int argc, char *argv[]) { err(EX_OSERR, "%s", cmd); } - // TODO: Kill child on error after this point? - error = listen(server, 1); if (error) err(EX_IOERR, "listen"); @@ -162,15 +161,15 @@ static int dtch(int argc, char *argv[]) { ssize_t len = sendFd(client, master); if (len < 0) warn("sendmsg(%d)", client); - // TODO: Send SIGWINCH? - len = recv(client, &z, sizeof(z), 0); if (len < 0) warn("recv(%d)", client); error = close(client); if (error) warn("close(%d)", client); - // TODO: Detect death of child. + pid_t dead = waitpid(pid, NULL, WNOHANG); + if (dead < 0) warn("waitpid(%d)", pid); + if (dead) exit(EX_OK); } } @@ -213,8 +212,6 @@ static int atch(int argc, char *argv[]) { error = ioctl(master, TIOCSWINSZ, &window); if (error) warn("ioctl(%d, TIOCSWINSZ)", master); - // TODO: Handle SIGWINCH? - struct pollfd fds[2]; fds[0].fd = STDIN_FILENO; fds[0].events = POLLIN; @@ -228,8 +225,7 @@ static int atch(int argc, char *argv[]) { if (len < 0) err(EX_IOERR, "read(%d)", STDIN_FILENO); if (len && buf[0] == CTRL('Q')) { - // TODO: Message? - exit(0); + exit(EX_OK); } len = writeAll(master, buf, len); -- cgit 1.4.1 068c69284c2a271b0e92&follow=1'>bin/README (unfollow)
Commit message (Expand)Author
2019-06-29Add Parable of the TalentsJune McEnroe
2019-06-28Rename catsh to 1shJune McEnroe
2019-06-28Set HISTSIZE in catshJune McEnroe
2019-06-28Unset iflag when exiting catshJune McEnroe
2019-06-24Consolidate catsh history documentationJune McEnroe
2019-06-19Set LESS=FRXJune McEnroe
2019-06-16Alias date=ddateJune McEnroe
2019-06-15Set sensitivity by slot in TF2June McEnroe
2019-06-15Add AcceptanceJune McEnroe
2019-06-07Add variables to bitJune McEnroe
2019-06-05Add A Closed and Common OrbitJune McEnroe
2019-06-02Add RebornJune McEnroe
2019-05-30Add bit to bin.7June McEnroe
2019-05-30Simplify and build bitJune McEnroe
2019-05-29Add xx -p optionJune McEnroe
2019-05-27Add FrontierJune McEnroe
2019-05-27Break nicks with ZWNJJune McEnroe
2019-05-26Add DawnJune McEnroe
2019-05-20Declare vasprintf(3) for GNUJune McEnroe
2019-05-20Fix comparison warning in ttpreJune McEnroe
2019-05-20Add AuthorityJune McEnroe
2019-05-19Specify precedence of unary versions of operatorsJune McEnroe
2019-05-18Add compound assignment operators to orderJune McEnroe
2019-05-15Support simple assignment in orderJune McEnroe
2019-05-15Implement sizeof in orderJune McEnroe
2019-05-15Add orderJune McEnroe
2019-05-12Add T suffix in bitJune McEnroe
2019-05-10Highlight yacc and lex files as CJune McEnroe
2019-05-10Use val instead of suboptargJune McEnroe
2019-05-09Add Parable of the SowerJune McEnroe
2019-05-07Add bit without buildJune McEnroe
2019-05-04Fix MANDIR typoJune McEnroe
2019-05-04Move relay to binJune McEnroe