unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Tomi Ollila <tomi.ollila@iki.fi>
To: David Edmondson <dme@dme.org>, Austin Clements <amdragon@MIT.EDU>,
	notmuch@notmuchmail.org
Subject: Re: [PATCH] Properly handle short writes in sigint handlers
Date: Fri, 23 Dec 2011 14:30:50 +0200	[thread overview]
Message-ID: <yf6fwgba2rp.fsf@taco2.nixu.fi> (raw)
In-Reply-To: <cunhb0rvhc6.fsf@hotblack-desiato.hh.sledj.net>

On Fri, 23 Dec 2011 08:10:33 +0000, David Edmondson <dme@dme.org> wrote:
> Sorry for being slow.
> 
> Can you describe the situation in which you expect a write to stderr to
> be a short write? (Without error.)

In the following hypothetical case (correct me if I'm wrong :):

* There is 4096 byte buffer in tty driver.
* Stderr is in blocking-mode (the usual case).
* There is already 4090 bytes in that buffer that has not been read.
* One attemtps to write "Stopping...         \n" there (blocks).
* Somehow the system call is interrupted (and SA_RESTART not set)
  -- write() should return 6 bytes written.

But, if the buffer is full already, does the write() system call return
with -1 and EINTR set ?

If there is enough space for all data in that buffer to begin with, 
write() should be atomic.

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

If write() keeps returning 0 then it will not terminate (I guess this never
happens). Also, it never terminates if write blocks indefinitely 
(with or without that loop).

> 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.

I'm also in favor of "opportunistic" write *in this particular case*

In case that write fails there is most probably more serious things going
on (all resources eaten, hardware problem, etc) and trying to push these
writes forward doesn't help.

Tomi

  reply	other threads:[~2011-12-23 12:31 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-21 21:38 [RFC][PATCH] notmuch: Workaround to allow ignoring non-void function return David Edmondson
2011-12-22  7:03 ` Austin Clements
2011-12-22  7:21   ` David Edmondson
2011-12-22 19:03     ` Austin Clements
2011-12-22 19:25       ` David Edmondson
2011-12-22 20:04         ` David Edmondson
2011-12-22 20:15         ` Austin Clements
2011-12-22 20:15           ` [PATCH] Properly handle short writes in sigint handlers Austin Clements
2011-12-23  8:10             ` David Edmondson
2011-12-23 12:30               ` Tomi Ollila [this message]
2011-12-25  0:38                 ` Austin Clements
2011-12-25  0:38               ` Austin Clements
2011-12-23 19:10             ` Dmitry Kurochkin
2012-01-10 11:13               ` David Bremner
2012-01-11 13:04                 ` Tomi Ollila
2011-12-22  9:32 ` [RFC][PATCH] notmuch: Workaround to allow ignoring non-void function return Dmitry Kurochkin
2011-12-22 11:24   ` David Edmondson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=yf6fwgba2rp.fsf@taco2.nixu.fi \
    --to=tomi.ollila@iki.fi \
    --cc=amdragon@MIT.EDU \
    --cc=dme@dme.org \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).