Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 12 Aug 2006 10:44:00 +0300
From:      Giorgos Keramidas <keramida@ceid.upatras.gr>
To:        Julian Elischer <julian@elischer.org>
Cc:        current@freebsd.org
Subject:   Re: suggested addition to 'date'
Message-ID:  <20060812074400.GA9572@gothmog.pc>
In-Reply-To: <44DD6CBC.9030309@elischer.org>
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>

next in thread | previous in thread | raw e-mail | index | archive | help
On 2006-08-11 22:53, Julian Elischer <julian@elischer.org> 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...




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