Date: Sat, 26 Jan 2008 21:50:02 GMT From: Jaakko Heinonen <jh@saunalahti.fi> To: freebsd-bugs@FreeBSD.org Subject: Re: bin/107171: [patch] systat(1) doesn't die when it's xterm is killed while it's running Message-ID: <200801262150.m0QLo28s023181@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
The following reply was made to PR bin/107171; it has been noted by GNATS. From: Jaakko Heinonen <jh@saunalahti.fi> To: bug-followup@FreeBSD.org, josh@tcbug.org Cc: Subject: Re: bin/107171: [patch] systat(1) doesn't die when it's xterm is killed while it's running Date: Sat, 26 Jan 2008 23:25:35 +0200 --T4sUOijqQbZv57TR Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Here's an updated patch against HEAD. I took the keyboard.c snippet from OpenBSD and added a signal handling for SIGHUP in main.c. --T4sUOijqQbZv57TR Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="systat-hang-on-getch-loop-fix.patch" Index: main.c =================================================================== RCS file: /home/ncvs/src/usr.bin/systat/main.c,v retrieving revision 1.21 diff -u -r1.21 main.c --- main.c 16 Jan 2008 19:27:43 -0000 1.21 +++ main.c 26 Jan 2008 21:01:28 -0000 @@ -136,6 +136,7 @@ signal(SIGINT, die); signal(SIGQUIT, die); signal(SIGTERM, die); + signal(SIGHUP, die); /* * Initialize display. Load average appears in a one line Index: keyboard.c =================================================================== RCS file: /home/ncvs/src/usr.bin/systat/keyboard.c,v retrieving revision 1.3 diff -u -r1.3 keyboard.c --- keyboard.c 16 Jan 2008 19:27:43 -0000 1.3 +++ keyboard.c 26 Jan 2008 21:01:28 -0000 @@ -39,6 +39,7 @@ static const char sccsid[] = "@(#)keyboard.c 8.1 (Berkeley) 6/6/93"; #endif +#include <errno.h> #include <ctype.h> #include <signal.h> #include <termios.h> @@ -57,7 +58,12 @@ move(CMDLINE, 0); do { refresh(); - ch = getch() & 0177; + if ((ch = getch()) == ERR) { + if (errno == EINTR) + continue; + exit(1); + } + ch &= 0177; if (ch == 0177 && ferror(stdin)) { clearerr(stdin); continue; --T4sUOijqQbZv57TR--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200801262150.m0QLo28s023181>