suggested addition to 'date'
Giorgos Keramidas
keramida at ceid.upatras.gr
Sat Aug 12 07:44:42 UTC 2006
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...
More information about the freebsd-current
mailing list