From: Roman Shaposhnik <rvs@sun.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: Sun, 19 Jul 2009 13:06:00 -0700 [thread overview]
Message-ID: <EEAEF7E0-CDF6-41EC-A79D-5234A0DD817A@sun.com> (raw)
In-Reply-To: <7b93f3ae1c310555bed9f828c4639fc7@quanstro.net>
On Jul 18, 2009, at 6:06 PM, erik quanstrom wrote:
> On Sat Jul 18 14:41:02 EDT 2009, rvs@sun.com wrote:
>> In the "mom, why sky is blue" department, here's a silly question:
>> is there any good reason that read(2) on a hangup channel returns
>> an error, while write(2) on a hangup channel terminates an
>> application
>> (by generating a note, of course, which can be ignored, but still)?
>
> hmm. from a quick read of port/sysfile.c, i think the precise
> behavior
> might depend on the underlying device. if devtab[m->c->type]->bread/
> bwrite
> are (ultimately) based on qbread and qbwrite, i read qio as saying
> that neither should
> generate a note.
>
> perhaps i've been asleep at the swtch, but i don't recall seing writes
> on closed channels terminate programs with a note.
Observe:
cpu% cat test2.c
#include <u.h>
#include <libc.h>
#include <stdio.h>
void notary(void *v, char* s)
{
fprintf(stderr, "NOTE: %s\n", s);
noted(NCONT);
}
int main()
{
notify(¬ary);
while (1) {
fprintf(stderr, "%d\n", write(1, "roman", 5));
sleep(5000);
}
return 0;
}
cpu% 8c test2.c
cpu% 8l test2.8
cpu% { ./8.out | cat } & { sleep 10 ; slay cat | rc }
5
roman5
romanNOTE: sys: write on closed pipe pc=0x00001525
-1
NOTE: sys: write on closed pipe pc=0x00001525
-1
NOTE: sys: write on closed pipe pc=0x00001525
-1
Thanks,
Roman.
next prev parent reply other threads:[~2009-07-19 20:06 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
2009-07-20 9:52 ` Charles Forsyth
2009-07-20 17:14 ` Roman V Shaposhnik
2009-07-19 20:06 ` Roman Shaposhnik [this message]
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=EEAEF7E0-CDF6-41EC-A79D-5234A0DD817A@sun.com \
--to=rvs@sun.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).