From owner-freebsd-current@FreeBSD.ORG Sat Aug 12 07:44:42 2006 Return-Path: X-Original-To: current@freebsd.org Delivered-To: freebsd-current@FreeBSD.ORG Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 7788A16A4DD for ; Sat, 12 Aug 2006 07:44:42 +0000 (UTC) (envelope-from keramida@ceid.upatras.gr) Received: from igloo.linux.gr (igloo.linux.gr [62.1.205.36]) by mx1.FreeBSD.org (Postfix) with ESMTP id A510943D49 for ; Sat, 12 Aug 2006 07:44:41 +0000 (GMT) (envelope-from keramida@ceid.upatras.gr) Received: from gothmog.pc (host5.bedc.ondsl.gr [62.103.39.229]) (authenticated bits=128) by igloo.linux.gr (8.13.7/8.13.7/Debian-2) with ESMTP id k7C7i6Hv017177 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Sat, 12 Aug 2006 10:44:07 +0300 Received: from gothmog.pc (gothmog [127.0.0.1]) by gothmog.pc (8.13.7/8.13.7) with ESMTP id k7C7i55X009821; Sat, 12 Aug 2006 10:44:06 +0300 (EEST) (envelope-from keramida@ceid.upatras.gr) Received: (from giorgos@localhost) by gothmog.pc (8.13.7/8.13.7/Submit) id k7C7i0qw009820; Sat, 12 Aug 2006 10:44:00 +0300 (EEST) (envelope-from keramida@ceid.upatras.gr) Date: Sat, 12 Aug 2006 10:44:00 +0300 From: Giorgos Keramidas To: Julian Elischer Message-ID: <20060812074400.GA9572@gothmog.pc> References: <44DD4510.5070002@elischer.org> <20060812033607.GB80768@gothmog.pc> <44DD50FF.5040406@elischer.org> <20060812041535.GA82669@gothmog.pc> <44DD5992.5080409@elischer.org> <20060812045622.GA84354@gothmog.pc> <44DD6CBC.9030309@elischer.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <44DD6CBC.9030309@elischer.org> X-Hellug-MailScanner: Found to be clean X-Hellug-MailScanner-SpamCheck: not spam, SpamAssassin (score=-3.818, required 5, autolearn=not spam, ALL_TRUSTED -1.80, AWL 0.58, BAYES_00 -2.60) X-Hellug-MailScanner-From: keramida@ceid.upatras.gr X-Spam-Status: No Cc: current@freebsd.org Subject: Re: suggested addition to 'date' X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 12 Aug 2006 07:44:42 -0000 On 2006-08-11 22:53, Julian Elischer wrote: >Giorgos Keramidas wrote: >>IIRC, stdio can buffer more than one line, so now that you mention it, >>maybe it is a good idea to flush at every '\n' character to make >>output appear every time there's a complete line ready. > > stdio will automatically flush pipe and terminal output at every \n. > the problem is if you are writing to a file. > If you get a signal it just calls _exit() which doesn't flush anything. > if it does an exit() it flushes the output so that would be ok. > signal handlers shouldn't call stdio as they are not async-safe, so making > a signal handler that calls fflush is not possible. > > I tried making the signal handler just set a variable that makes the > main loop quit, flush and exit, > but believe it or not, fgets() doesn't return from a signal. so you hit > ^C but it doesn't notice the flag that is set until > you then hit CR. hmm maybe if the signal handler closed file descriptor > 0....... This is getting too complex for my taste though. I don't see cat(1) doing signal trickery, so why should date(1) do these things? Perhaps it's not a good idea to 'bloat' date(1) so much...