Re: [PATCH] Properly handle short writes in sigint handlers

Subject: Re: [PATCH] Properly handle short writes in sigint handlers

Date: Sat, 24 Dec 2011 19:38:42 -0500

To: David Edmondson

Cc: notmuch@notmuchmail.org

From: Austin Clements


Quoth David Edmondson on Dec 23 at  8:10 am:
> Sorry for being slow.
> 
> Can you describe the situation in which you expect a write to stderr to
> be a short write? (Without error.)

If the PTY buffer is nearly full because, say, my terminal emulator is
a little behind or my SSH session is slow, I believe POSIX allows this
to be a short write (though Linux appears to treat PTYs like pipes and
will block rather than doing a short write, so it's completely
possible I'm misinterpreting POSIX).

> In that situation, what guarantee is there that the loop you've written
> will terminate?

There isn't, but for the same reason there's also no guarantee that a
single write will terminate.

> We're not talking about safeguarding a users' data here - this is a
> short message to indicate that a tool is terminating due to a signal.
> I'm concerned that the solution is worse than the problem.

As a user I'd be confused to see just part of the "Stopping" message
jammed in the middle of other output, but you're definitely right that
the consequences of this would not extend beyond a little bit of
harmless confusion.

Thread: