Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 21 May 2010 16:03:57 +0000 (UTC)
From:      Jaakko Heinonen <jh@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org
Subject:   svn commit: r208381 - stable/7/usr.bin/systat
Message-ID:  <201005211603.o4LG3v4p063070@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jh
Date: Fri May 21 16:03:57 2010
New Revision: 208381
URL: http://svn.freebsd.org/changeset/base/208381

Log:
  MFC r197956:
  
  - Catch SIGHUP to perform cleanup before exiting.
  - Exit if getch() returns with an error other than EINTR. Otherwise
    systat(1) may get stuck in an infinite loop if it doesn't receive
    SIGHUP when terminal closes.
  - Remove attempt to clear stdio error indicators. getch() doesn't use
    stdio, making it useless.
  - Remove unneeded masking of getch() return value.
  
  PR:		bin/107171

Modified:
  stable/7/usr.bin/systat/keyboard.c
  stable/7/usr.bin/systat/main.c
Directory Properties:
  stable/7/usr.bin/systat/   (props changed)

Modified: stable/7/usr.bin/systat/keyboard.c
==============================================================================
--- stable/7/usr.bin/systat/keyboard.c	Fri May 21 16:01:57 2010	(r208380)
+++ stable/7/usr.bin/systat/keyboard.c	Fri May 21 16:03:57 2010	(r208381)
@@ -39,8 +39,10 @@ __FBSDID("$FreeBSD$");
 static const char sccsid[] = "@(#)keyboard.c	8.1 (Berkeley) 6/6/93";
 #endif
 
+#include <errno.h>
 #include <ctype.h>
 #include <signal.h>
+#include <stdlib.h>
 #include <termios.h>
 
 #include "systat.h"
@@ -57,10 +59,11 @@ keyboard()
                 move(CMDLINE, 0);
                 do {
                         refresh();
-                        ch = getch() & 0177;
-                        if (ch == 0177 && ferror(stdin)) {
-                                clearerr(stdin);
-                                continue;
+                        ch = getch();
+                        if (ch == ERR) {
+                                if (errno == EINTR)
+                                        continue;
+                                exit(1);
                         }
                         if (ch >= 'A' && ch <= 'Z')
                                 ch += 'a' - 'A';

Modified: stable/7/usr.bin/systat/main.c
==============================================================================
--- stable/7/usr.bin/systat/main.c	Fri May 21 16:01:57 2010	(r208380)
+++ stable/7/usr.bin/systat/main.c	Fri May 21 16:03:57 2010	(r208381)
@@ -133,6 +133,7 @@ main(int argc, char **argv)
 			exit(1);
 		}
 	}
+	signal(SIGHUP, die);
 	signal(SIGINT, die);
 	signal(SIGQUIT, die);
 	signal(SIGTERM, die);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201005211603.o4LG3v4p063070>