9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: roger peppe <rogpeppe@gmail.com>
To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net>
Subject: Re: [9fans] i/o on a hangup channel asymmetry
Date: Thu, 23 Jul 2009 13:15:06 +0100	[thread overview]
Message-ID: <df49a7370907230515h3ca1c200r81afb11fca44f8f8@mail.gmail.com> (raw)
In-Reply-To: <dd669f2c79418e4b94833a3db9b18616@quanstro.net>

one example of this behaviour that i use
all the time is:

  tar t < foo.tar | sed 10q

just to get some idea of the contents of foo.tar.
often the tar file is huge, and i won't get a command
prompt back until all the elements of the pipeline
have completed - whereas i want it to finish quickly.

it always annoys me when gnu tar prints
something like:

tar: Error in writing to standard output
tar: Error is not recoverable: exiting now

in this situation, where a silent exit is more appropriate.

> also, the only case that is a problem is
> when the return status of writes is not checked.

it's often much more of a hassle to check the
return status of all writes, as many programs will
use print(f) in many places, all of which would
have to be wrapped appropriately.

i think the fundamental asymmetricality
between read and write is one of knowledge:

- on a write, the program knows what it's producing,
and if the consumer isn't ready for it, that's
almost always an error. in a pure pipeline,
one where each component has no side effects,
if you can't write data, there's nothing more you
can do, so you might as well be dead.

- on a read, the program usually doesn't know exactly what
it's getting so it's in a good position to act appropriately
on an unexpected situation. most
programs will produce data into the pipeline
after all input data has been read, error or not,
so it's rarely appropriate for the program to die
after a read error.

mind you, i seem to remember that inferno's pipe
write (at least) generates an exception on the first
write to a defunct pipe. i think it should return -1
at least once before raising the exception, so
a program that checks the return code should never
encounter the exception.

that seems like a good compromise to me.



  reply	other threads:[~2009-07-23 12:15 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-18 18:39 Roman V. Shaposhnik
2009-07-19  1:06 ` erik quanstrom
2009-07-19  9:30   ` Charles Forsyth
2009-07-19 20:32     ` Roman Shaposhnik
2009-07-19 21:01       ` Francisco J Ballesteros
2009-07-20  4:49         ` Roman Shaposhnik
2009-07-20  9:53           ` Charles Forsyth
2009-07-20 17:01             ` Roman V Shaposhnik
2009-07-20 18:38               ` Charles Forsyth
2009-07-19 21:11     ` Mechiel Lukkien
2009-07-19 21:55       ` Charles Forsyth
2009-07-20  4:52         ` Roman Shaposhnik
2009-07-20  5:21           ` erik quanstrom
2009-07-20 16:53             ` Roman V Shaposhnik
2009-07-21  1:01               ` erik quanstrom
2009-07-21  2:04                 ` Russ Cox
2009-07-21  2:15                   ` erik quanstrom
2009-07-23 12:15                     ` roger peppe [this message]
2009-07-20  9:52           ` Charles Forsyth
2009-07-20 17:14             ` Roman V Shaposhnik
2009-07-19 20:06   ` Roman Shaposhnik
2009-07-19 20:22     ` erik quanstrom

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

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

  git send-email \
    --in-reply-to=df49a7370907230515h3ca1c200r81afb11fca44f8f8@mail.gmail.com \
    --to=rogpeppe@gmail.com \
    --cc=9fans@9fans.net \
    /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.
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 NNTP newsgroup(s).