From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13904 invoked from network); 1 Jun 2005 14:48:21 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 1 Jun 2005 14:48:21 -0000 Received: (qmail 35020 invoked from network); 1 Jun 2005 14:48:14 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 1 Jun 2005 14:48:14 -0000 Received: (qmail 21892 invoked by alias); 1 Jun 2005 14:48:07 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 8929 Received: (qmail 21882 invoked from network); 1 Jun 2005 14:48:06 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 1 Jun 2005 14:48:06 -0000 Received: (qmail 33849 invoked from network); 1 Jun 2005 14:48:06 -0000 Received: from mailhost1.csr.com (HELO MAILSWEEPER01.csr.com) (81.105.217.43) by a.mx.sunsite.dk with SMTP; 1 Jun 2005 14:48:00 -0000 Received: from exchange03.csr.com (unverified [10.100.137.60]) by MAILSWEEPER01.csr.com (Content Technologies SMTPRS 4.3.12) with ESMTP id for ; Wed, 1 Jun 2005 15:46:09 +0100 Received: from news01.csr.com ([10.103.143.38]) by exchange03.csr.com with Microsoft SMTPSVC(5.0.2195.6713); Wed, 1 Jun 2005 15:49:59 +0100 Received: from news01.csr.com (localhost.localdomain [127.0.0.1]) by news01.csr.com (8.13.1/8.12.11) with ESMTP id j51ElwVo013730 for ; Wed, 1 Jun 2005 15:47:59 +0100 Received: from csr.com (pws@localhost) by news01.csr.com (8.13.1/8.13.1/Submit) with ESMTP id j51Elwh2013726 for ; Wed, 1 Jun 2005 15:47:58 +0100 Message-Id: <200506011447.j51Elwh2013726@news01.csr.com> X-Authentication-Warning: news01.csr.com: pws owned process doing -bs To: zsh-users@sunsite.dk Subject: Re: named pipes blocking zsh In-reply-to: References: Date: Wed, 01 Jun 2005 15:47:58 +0100 From: Peter Stephenson X-OriginalArrivalTime: 01 Jun 2005 14:49:59.0837 (UTC) FILETIME=[2F4B3CD0:01C566B9] X-Spam-Checker-Version: SpamAssassin 3.0.2 on a.mx.sunsite.dk X-Spam-Level: X-Spam-Status: No, score=-2.6 required=6.0 tests=AWL,BAYES_00 autolearn=ham version=3.0.2 X-Spam-Hits: -2.6 "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 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. **********************************************************************