From owner-freebsd-bugs@FreeBSD.ORG Fri Mar 9 03:10:13 2007 Return-Path: X-Original-To: freebsd-bugs@hub.freebsd.org Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 36DD416A401 for ; Fri, 9 Mar 2007 03:10:13 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [69.147.83.40]) by mx1.freebsd.org (Postfix) with ESMTP id D71B113C461 for ; Fri, 9 Mar 2007 03:10:12 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.4/8.13.4) with ESMTP id l293ACDf062956 for ; Fri, 9 Mar 2007 03:10:12 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.4/8.13.4/Submit) id l293ACmr062955; Fri, 9 Mar 2007 03:10:12 GMT (envelope-from gnats) Date: Fri, 9 Mar 2007 03:10:12 GMT Message-Id: <200703090310.l293ACmr062955@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org From: Nate Eldredge Cc: Subject: Re: bin/107171: [patch] systat(1) doesn't die when it's xterm is killed while it's running X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Nate Eldredge List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 09 Mar 2007 03:10:13 -0000 The following reply was made to PR bin/107171; it has been noted by GNATS. From: Nate Eldredge To: bug-followup@FreeBSD.org, josh@tcbug.org, bde@zeta.org.au Cc: Subject: Re: bin/107171: [patch] systat(1) doesn't die when it's xterm is killed while it's running Date: Thu, 8 Mar 2007 19:09:22 -0800 (PST) Bruce Evans wrote: > However, EINTR is probably irrelevant for the current bug. systat > doesn't catch SIGHUP in order to clean up up unsafely like it does > for SIGINT, so any SIGHUP that gives EOF on the terminal would either: > - kill the process uncleanly, or > - not be delivered to the process because it is masked (no EINTR since > it is not caught), or > - not be delivered to the process because of job control stuff. I included the EINTR handling because systat does use SIGALRM. In fact it actually does all the display updating inside the SIGALRM handler (nice huh?). If we are sure that restarting syscalls are in effect (systat does not explicitly select this behavior), then I agree that systat can die on EINTR like any other error. But if not then EINTR could legitimately appear every time the alarm rings, and the correct behavior is to retry. > So systat just needs a simple check for EOF from getch() and the > remainly problem is that getch(), like getc(), unimproves on read() > by not having any way to distinguish the non-error of EOF from errors. Note getch() returns ERR, not EOF. (In the current implementation they are both equal to -1.) getc() is actually okay; when getc() returns EOF you can use ferror(f) and feof(f) to decide if it was an error or end-of-file. But yes, with getch() you're stuck. I guess because it's normally used on a terminal device in raw mode, where you wouldn't normally receive an end-of-file (since ^D wouldn't work). -- Nate Eldredge nge@cs.hmc.edu