help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: possible to use a function that uses a coproc in a pipeline?


From: Chet Ramey
Subject: Re: possible to use a function that uses a coproc in a pipeline?
Date: Mon, 3 Apr 2023 15:39:32 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.8.0

On 3/31/23 5:47 PM, Britton Kerin wrote:
Overview:

I've been playing around more with coproc and I ran into an issue
trying to use a function that uses a server coproc in a pipeline.  It
doesn't work and I can't see how to make it work without
pipe ends available in subshells.  I wonder if I'm missing some
obvious way or if it might be possible to add an option to coproc to
not close the pipe ends?

Bash is pretty careful to close pipe file descriptors on exec, since a
stray open one can lead to hangs and deadlocks.

You can use the `fdflags' loadable builtin together with redirection to
copy whichever file descriptor you want and manipulate it. So if you
want to use a copy of ${sqliteServer[1]}, you use

exec {fdcopy}<&${sqliteServer[1]}
fdflags -s -cloexec ${fdcopy}

and then use ${fdcopy}.

You'll just have to keep the file descriptors straight manually.

--
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://tiswww.cwru.edu/~chet/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]