Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: runaway zselect
- X-seq: zsh-users 14127
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Re: runaway zselect
- Date: Sun, 17 May 2009 14:47:47 -0700
- In-reply-to: <20090517044323.15333.qmail@xxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <20090517044323.15333.qmail@xxxxxxxxxxx>
On May 17, 4:43pm, Atom Smasher wrote:
}
} i would expect zselect to return an error and stop the while loop when
} "w" stops producing output.
That's not how the select() system call works. The descriptor is still
open on the reading end of the pipe even though the descriptor on the
writing end of the pipe has been closed. That means from select()'s
point of view, the descriptor is available for reading, even though the
only thing that can be read from it is the end-of-file condition.
If this were not the case, zselect would fail as soon as the writer
exits, even if all output from the writer had not yet been consumed.
(Remember that there is OS-level buffering involved, so the writing
end may be closed before the pipe is "empty".)
What you need to fix this is to test the result of "read" as well.
Either:
while zselect -r 0 && read -r foo
do
print -r -- $foo
done <<( w )
Or equivalently:
while zselect -r 0
do
read -r foo || break
print -r -- $foo
done <<( w )
Messages sorted by:
Reverse Date,
Date,
Thread,
Author