What starts new subshell in Bash?
A开发者_如何学运维re there actions in Bash other than pipes and command substitution that start a new subshell?
Putting a command chain in parens (( ... )
) also starts a new subshell.
( cd /tmp ; pwd ) ; pwd
Each shell script running is, in effect, a subprocess (child process) of the parent shell.
A shell script can itself launch subprocesses. These subshells let the script do parallel processing, in effect executing multiple subtasks simultaneously.
say you have script test.sh
. After you run it if you run the command
ps -ef|grep -i test.sh
you will see the it runs with different PID
In general, an external command in a script forks off a subprocess/subshell
精彩评论