bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: yesno module consumes too much input


From: Bruno Haible
Subject: Re: yesno module consumes too much input
Date: Sun, 19 Aug 2007 01:12:02 +0200
User-agent: KMail/1.5.4

Eric Blake wrote:
> > To make this API more easy to understand, how about this?
> >   1) Rename the function 'close_stdin' to 'close_stdin_stdout',
> >   2) Add a function 'close_stdin', which closes stdin only. In the
> >      implementation, arrange that when 'close_stdin' and 
> > 'close_stdin_stdout'
> >      are both called, the stdin part is done only once.
> >   3) Don't add a 'close_stdin_only' setter.
> 
> As in the following?

Yes, roughly.

> Note that I still have a question on behavior.  There is no way to query
> what has previously been registered via atexit, so in this sequence:
> 
> atexit(close_stdout);
> atexit(close_stdin);
> 
> results in calling close_stdin first.  From there, if close_stdin detects
> an error, there is the potential for stdout/stderr to be unflushed (and
> thus output data lost) when close_stdin calls _exit.

I would just document that close_stdout and close_stdin are incompatible,
and that close_stdin_stdout should be used instead of the two together.
You can see that in coreutils, these functions are only used with atexit,
at exactly one place in main(). The maintainer can statically determine
whether he needs close_stdin or not, and if so, use close_stdin_stdout.

Bruno





reply via email to

[Prev in Thread] Current Thread [Next in Thread]