From the bash manual
Process substitution is supported on systems that support named pipes
(fifos) or the/dev/fd
method of naming open files. It takes the form
of<(list)
or
>(list)
The process
list is run with its input or output connected to a fifo or some file
in/dev/fd
. The name of this file is passed as an argument to the
current command as the result of the expansion.
Is the command list
in a process substitution <(list)
or >(list)
invoked in a subshell, similarly to a command substitution, commands grouped with parentheses, and
asynchronous commands? Similar as the bash manual says
Command substitution, commands grouped with parentheses, and
asynchronous commands are invoked in a subshell environment that
is a duplicate of the shell environment, except that traps caught by
the shell are reset to the values that the shell inherited from its
parent at invocation.
-
The answer might be yes, because
-
process substitution looks similar to command substitution,
-
some source says that
the command inside it is run in the background.
and the above second quote from the bash manual says that both command
substitution and backgrounded commands are invoked in subshells. -
-
The answer might be no, because
-
In the bash manual, I didn't see that a process substitution is mentioned in the above second quote from the bash manual,
-
and some source says that process substitution
is especially important for bypassing subshells caused by pipelines
although I am not sure if "bypassing subshells" means not being invoked in a subshell.
-
Best Answer
Running the current shell under
strace(1)
and then executing e.g.<(command)
gives:From a purely definitional standpoint, since clone(2) is defined as
and a subshell as
one could say that yes - running process substitution is invoked as a subshell.