From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-users@sunsite.dk
Subject: Re: runaway zselect
Date: Sun, 17 May 2009 14:47:47 -0700 [thread overview]
Message-ID: <090517144747.ZM959@torch.brasslantern.com> (raw)
In-Reply-To: <20090517044323.15333.qmail@smasher.org>
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 )
next prev parent reply other threads:[~2009-05-17 21:48 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-05-17 4:43 Atom Smasher
2009-05-17 7:58 ` Atom Smasher
2009-05-17 21:47 ` Bart Schaefer [this message]
2009-05-17 23:28 ` Atom Smasher
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=090517144747.ZM959@torch.brasslantern.com \
--to=schaefer@brasslantern.com \
--cc=zsh-users@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).