[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Examples of concurrent coproc usage?
From: |
Martin D Kealey |
Subject: |
Re: Examples of concurrent coproc usage? |
Date: |
Sun, 9 Jun 2024 13:37:54 +1200 |
On Wed, 10 Apr 2024 at 03:58, Carl Edquist <edquist@cs.wisc.edu> wrote:
> Note the coproc shell only does this with pipes; it leaves other user
> managed fds like files or directories alone.
>
> I have no idea why that's the case, and i wonder whether it's intentional
> or an oversight.
>
Simply closing all pipes is definitely a bug.
This is starting to feel like we really need explicit ways to control
attributes on filedescriptors.
It should be possible to arrange so that any new subshell will keep
"emphemal" filedescriptors until just before invoking a command.
One mechanism would be to add two new per-fd attributes: *inherited-by-fork*,
and *ephemeral*.
The *inherited-by-fork* attribute would be set on any fd that's carried
through a fork (especially the implicit fork to create a pipeline) and
reset on any fd that's the result of a redirection.
The *emphemal* attribute is set on any coproc fd (or at least, any that's a
pipe to the stdin of a coproc).
Then when *both* attributes are set on an fd, it would be closed just
before launching any inner command, after any redirections have been
done.That way we could simply turn off the close-after-fork attribute on a
coproc fd if that's desired, but otherwise avoid deadlocks in the simple
cases.
-Martin
- Re: Examples of concurrent coproc usage?,
Martin D Kealey <=