Re: name pipe problem, quick question

From: Lew Pitcher (Lew.Pitcher_at_td.com)
Date: 06/11/04


Date: Fri, 11 Jun 2004 15:06:44 -0400


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

187 wrote:

> "Richard Tobin" <richard@cogsci.ed.ac.uk> wrote in message
> news:cacln2$7j6$1@pc-news.cogsci.ed.ac.uk...
>
>>In article <2itvdsFqt04iU1@uni-berlin.de>,
>>187 <bigal187.invalid@adexec.com> wrote:
>>
>>
>>>>>rm $b/cmd-1
>>>>>mkfifo $b/cmd-1
>>>>>rm $b/res-1
>>>>>mkfifo $b/res-1
>>>>
>>>> [...]
>>>>
>>>>>echo "" > $b/cmd-1&
>>
>>>>your script stops here, waiting for something to open $b/cmd-1 for
>>>>reading.
>>
>>>How can I fix the problem? Any suggestions?
>>
>>Don't write to the named pipes until the program is listening on them.
>
>
> I'm not entirely sure what I'm doing (I've never worked with named pipes
> before), could you please elaborate a little? What do you mean exactly?

Unless the programs handle named pipes with special settings
(O_NONBLOCK, IIRC), you get blocking behaviour by default.

A named pipe can have multiple writers, but only one reader. Any process
that opens the pipe for writing blocks until the pipe has also been
opened for reading. Any process that opens the pipe for reading blocks
on the first read until the pipe has been opened for writing.

The only way around this is to open the pipe in non-blocking mode, and
you can't do this in a script.

- --

Lew Pitcher, IT Consultant, Enterprise Application Architecture
Enterprise Technology Solutions, TD Bank Financial Group

(Opinions expressed here are my own, not my employer's)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (MingW32)

iD8DBQFAygLCagVFX4UWr64RAkNfAKDqf4IpcMR34/+SXCo2JIHO6uuT7ACfa4S7
GYvOhWNRxjhXZBxiCqzYMEM=
=InmX
-----END PGP SIGNATURE-----