There are this two names: a subshell and a child-shell.
Yes, a child process will be started by any of this:
sh -c 'echo "Hello"'
( echo "hello" )
echo "$(echo "hello")
echo "hello" | cat
Are all equivalent and share the same name? Do all share the same properties?
POSIX has this definition:
A shell execution environment consists of ....
But the last paragraph of above link has this:
A subshell environment shall be created as a duplicate of the shell environment, except that signal traps that are not being ignored shall be set to the default action.
And specially:
Command substitution, commands that are grouped with parentheses, and asynchronous lists shall be executed in a subshell environment. Additionally, each command of a multi-command pipeline is in a subshell environment; ....
The sh -c 'echo "Hello"'
is not included there, should that be called a subshell also?
sh -c
: that's a subprocess that coincidentally happens to be a shell. – Gilles 'SO- stop being evil' Feb 12 '16 at 00:53bash -c <command>
, after fork the shell and then execvebash -c <command>
, a bash shell is created. Then are the system call used to run<command>
again fork the bash shell and execve<command>
? – Tim Feb 12 '16 at 01:42