Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: PATCH: zselect builtin.
- X-seq: zsh-workers 17126
- From: Borsenkow Andrej <Andrej.Borsenkow@xxxxxxxxxxxxxx>
- To: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- Subject: Re: PATCH: zselect builtin.
- Date: 12 May 2002 14:42:07 +0400
- Cc: Peter Stephenson <pws@xxxxxxx>, Zsh hackers list <zsh-workers@xxxxxxxxxx>
- In-reply-to: <1020508155545.ZM7875@xxxxxxxxxxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
- References: <8259.1020851945@xxxxxxx> <1020508155545.ZM7875@xxxxxxxxxxxxxxxxxxxxxxx>
В Срд, 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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author