I know that grouping commands(command-list)
creates a subshell environment, and each listed command is executed in that subshell. But if I execute a simple command in the grouping command, (use the ps
command to output the processes), then no subshell process is output. But if I tried to execute a list of commands (compound command) in the grouping command, then a subshell process is output. Why does it produce such a result?
- A test of executing a simple command (only a
ps
command) in a grouping command:
with the following output:[root@localhost ~]# (ps -f)
UID PID PPID C STIME TTY TIME CMD root 1625 1623 0 13:49 pts/0 00:00:00 -bash root 1670 1625 0 15:05 pts/0 00:00:00 ps -f
- Another test of executing a compound command(a list of commands) in a grouping command:
with the following output:[root@localhost ~]# (ps -f;cd)
UID PID PPID C STIME TTY TIME CMD root 1625 1623 0 13:49 pts/0 00:00:00 -bash root 1671 1625 0 15:05 pts/0 00:00:00 -bash root 1672 1671 0 15:05 pts/0 00:00:00 ps -f
I tested a lot of other commands (compound commands and simple commands), but the results are the same. I guess even if I execute a simple command in a grouping command, bash
should fork a subshell process, otherwise it can't execute the command. But why can't I see it?