zsh-users
 help / color / mirror / code / Atom feed
From: Peter Stephenson <pws@csr.com>
To: zsh-users@sunsite.dk
Subject: Re: named pipes blocking zsh
Date: Wed, 01 Jun 2005 15:47:58 +0100	[thread overview]
Message-ID: <200506011447.j51Elwh2013726@news01.csr.com> (raw)
In-Reply-To: <d7kfuc$gem$1@sea.gmane.org>

"Tim K. (Gmane)" wrote:
> I have a situtation with zsh: I use pine as my mail reader and it has a 
> feature where it can create a named pipe (FIFO) and write to it when new 
> mail arrives. Naturally, I thought of writing a script at the other end 
> of the pipe that reads the messages and sends me notifications in some 
> other way.
> 
> The way I have it set up is to have a zsh script that starts another 
> "notify" child zsh script that reads from the pipe and does its 
> notification thing and then the main script calls pine.
> 
> This all seems to work, except when I quit pine, hence terminating the 
> main "parent" script, the child "notify" script does not exit, it's 
> stuck reading from the pipe (even though the pipe is deleted). The child 
> script becomes owned by PPID 1 and the only way to kill it is kill -9 ...
> 
> I'm reading with the built in "read var < pine_pipe" which blocks until 
> the first line of data is written to the pipe by pine. I also tried 
> "read -t" but it doesn't react to the timeout. Also tried the zselect 
> module, with and without timeouts, nothing works. If there's nothing in 
> the pipe, the zsh process just hangs until there is data.

I'm not sure how much the shell can do about this...

The shell is actually blocking in the "open" call to pine_pipe, not in
the builtin itself.  This is the way reading from pipes works: you can't
open the pipe until someone is writing to it.  If the open fails, it's up
to the system to tell the shell, which will find out as soon as the call
returns, and can't very well find out it before.

It's possible to open without blocking, but that's not actually what you
want:  you need to blocking behaviour to be able to open the pipe when
the other side writes to it.

I can't offhand think of a simple solution.

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070


**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

**********************************************************************


      parent reply	other threads:[~2005-06-01 14:48 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-06-01 14:18 Tim K. (Gmane)
2005-06-01 14:47 ` Bart Schaefer
2005-06-01 15:20   ` Tim K. (Gmane)
2005-06-01 15:36     ` Peter Stephenson
2005-06-01 15:45     ` Bart Schaefer
2005-06-01 15:24   ` Tim K. (Gmane)
2005-06-01 14:47 ` Peter Stephenson [this message]

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=200506011447.j51Elwh2013726@news01.csr.com \
    --to=pws@csr.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).