zsh-workers
 help / color / mirror / code / Atom feed
From: Borsenkow Andrej <Andrej.Borsenkow@mow.siemens.ru>
To: Bart Schaefer <schaefer@brasslantern.com>
Cc: Peter Stephenson <pws@csr.com>,
	Zsh hackers list <zsh-workers@sunsite.dk>
Subject: Re: PATCH: zselect builtin.
Date: 12 May 2002 14:42:07 +0400	[thread overview]
Message-ID: <1021200133.2915.12.camel@localhost.localdomain> (raw)
In-Reply-To: <1020508155545.ZM7875@candle.brasslantern.com>

В Срд, 08.05.2002, в 19:55, Bart Schaefer написал:
> On May 8, 10:59am, Peter Stephenson wrote:
> } Subject: Re: PATCH: zselect builtin.
> }
> } > Aso you probably can't fully utilize select without non-blocking I/O.
> } 
> } I don't see this; you can already poll a blocking fd using a zero
> } timeout.
> 
> The problem is not blocking reads, but blocking *writes*.
> 
> However, even non-blocking write is not sufficient if you can't find out
> what subset of the bytes got written and try again with the remainder.
> 

Right. We could make print return number of characters written. For
non-printf case it is pretty trivial - it just amounts to

	iocount = 0;
	for (; *args; args++, len++) {
	    iocount += fwrite(*args, *len, 1, fout);
	    if (args[1] && (EOF !=
		fputc(ops['l'] ? '\n' : ops['N'] ? '\0' : ' ', fout))
		iocount++;
	}
        setiparam("IOCONUNT", iocount);

for printf-like case it is not quite as simple due to large number of
idividual putc's; also it is not clear if it is needed at all (I do not
see how it can be used).

The same is true of read of course. Both can set IOCOUNT indicating
number of characters transmitted in last call.

Alternative is to add raw write function. 

It is user responsibility then to ensure print does not mangle output
string (i.e. call it with -r and possible -n). Usage is obvious

while true; do
  ....
  zselect -w $d
  print -rnu$d $buffer
  (( IOCOUNT )) || break # EOF
  (( IOCOUNT == $#buffer )) || break # IO error
  ....
done

-andrej


  reply	other threads:[~2002-05-12 10:42 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-05-07 11:25 Peter Stephenson
2002-05-07 14:46 ` Bart Schaefer
2002-05-07 17:01   ` Peter Stephenson
2002-05-07 19:01     ` Bart Schaefer
2002-05-08  5:36 ` Borsenkow Andrej
2002-05-08  9:59   ` Peter Stephenson
2002-05-08 15:55     ` Bart Schaefer
2002-05-12 10:42       ` Borsenkow Andrej [this message]
2002-05-14  9:18         ` Oliver Kiddle
2002-05-08 13:26 ` Peter Stephenson
2002-05-08 13:37   ` PATCH: zselect bug, already Peter Stephenson
2002-05-08 15:34   ` Module loading by name (Re: PATCH: zselect builtin.) Bart Schaefer
2002-05-08 17:23   ` PATCH: zselect builtin Peter Stephenson
2002-05-08 17:49     ` Peter Stephenson
2002-05-13  9:06       ` Sven Wischnowsky

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=1021200133.2915.12.camel@localhost.localdomain \
    --to=andrej.borsenkow@mow.siemens.ru \
    --cc=pws@csr.com \
    --cc=schaefer@brasslantern.com \
    --cc=zsh-workers@sunsite.dk \
    /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://git.vuxu.org/mirror/zsh/

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