9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: forsyth@vitanuova.com
To: 9fans@cse.psu.edu
Subject: Re: [9fans] weird print(2) problems...
Date: Wed,  5 Sep 2001 16:11:58 +0100	[thread overview]
Message-ID: <20010905150808.1FC2619A32@mail.cse.psu.edu> (raw)

[-- Attachment #1: Type: text/plain, Size: 996 bytes --]

>>that if write(2) sees a zero length argument, it should consider that a
>>nop and return.  But then it seems that that would break some weird
>>semantic somewhere (``Any write will update a timestamp; except for
>>zero length writes, which are ignored.'' ``Dude, that's broken.'')

it isn't only the possible effect on time stamps; i think it
should do a write 0 because it's what you said to do.
to be fair, it's disguised by print, but even so,
if i wanted nop() i'd use
	;
or
	void nop(void){}
but i wouldn't call write() or even print.  i'd call write() when i wanted to write,
and i prefer systems that do what i tell it, so that if i say `write 0 bytes'
i expect it to do that, rather than adding yet
more special cases to remember.   the effect of writing 0 bytes
is determined by the device, but that's true of writing 1 byte or many,
so there's no difference there.

on the other hand, i'd probably write
	if(*str)
		print("%s", str);
if that's what i wanted.


[-- Attachment #2: Type: message/rfc822, Size: 2476 bytes --]

To: 9fans@cse.psu.edu
Cc: 
Subject: Re: [9fans] weird print(2) problems...
Date: Wed, 5 Sep 2001 10:22:18 -0400 (EDT)
Message-ID: <200109051422.KAA02761@augusta.math.psu.edu>

In article <20010904190825.3180.qmail@f.bio.cse.psu.edu> you write:
>Hm.  Pipes in Plan 9 preserve write boundaries, right?  Print is probably
>sending a zero length write, and confusing programs that interpret it
>as eof.

Hmm, that seems plausible.  It's also rather annoying; it seems to me
that if write(2) sees a zero length argument, it should consider that a
nop and return.  But then it seems that that would break some weird
semantic somewhere (``Any write will update a timestamp; except for
zero length writes, which are ignored.'' ``Dude, that's broken.'')

Is there an elegant solution (other than ``don't do print("");'',
since that might really mean ``don't do,

	read(0, str, 128);
	trimwhitespace(str);
	print("%s", str);

where the only thing read is a blank line or something.'')?

	- Dan C.

             reply	other threads:[~2001-09-05 15:11 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-09-05 15:11 forsyth [this message]
2001-09-05 18:23 ` Dan Cross
2001-09-05 19:10   ` Boyd Roberts
  -- strict thread matches above, loose matches on Subject: below --
2001-09-11 11:16 rob pike
     [not found] <rsc@plan9.bell-labs.com>
2001-09-05 21:11 ` Russ Cox
2001-09-05 21:24   ` Scott Schwartz
2001-09-05 19:46 Russ Cox
2001-09-05 19:19 Russ Cox
2001-09-05 19:40 ` Boyd Roberts
2001-09-06  8:19 ` Matthew Hannigan
2001-09-06 16:18 ` Douglas A. Gwyn
2001-09-06 20:45   ` Boyd Roberts
2001-09-05 18:40 Russ Cox
2001-09-05 19:58 ` Dan Cross
     [not found] <cross@math.psu.edu>
2001-09-04 19:02 ` Dan Cross
2001-09-04 19:08   ` Scott Schwartz
2001-09-05 14:22     ` Dan Cross
2001-09-05 19:01       ` Boyd Roberts

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=20010905150808.1FC2619A32@mail.cse.psu.edu \
    --to=forsyth@vitanuova.com \
    --cc=9fans@cse.psu.edu \
    /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).