Re: suggested addition to 'date'

From: Giorgos Keramidas <keramida_at_ceid.upatras.gr>
Date: Sat, 12 Aug 2006 10:44:00 +0300
On 2006-08-11 22:53, Julian Elischer <julian_at_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...
Received on Sat Aug 12 2006 - 05:44:42 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:38:58 UTC