While investigating the problem of redirecting the
stderr of the
time and the standard solution to the problem, I came across another question.
man bash gives of the
(list) compound command is list is executed in a subshell environment. Now, as you can see from the execution of the little program
hello- which makes the simple
system("ps -opid,ppid,comm") call, it looks there is no difference at all between the
./hello command lines. That came as a surprise to me. However I understand there is a difference when the command is a built-in one. In this case, with no parentheses no fork will take place but one would with the parentheses around the built-in command. Am I missing anything?
18:59:13 -> echo $$ 5323 19:34:30 -> ./hello hello world from process ID 8657, parent ID 5323 PID PPID COMM 5323 5322 -bash 8657 5323 ./hello 19:42:34 -> (./hello) hello world from process ID 8977, parent ID 5323 PID PPID COMM 5323 5322 -bash 8977 5323 ./hello 19:42:43 -> time (./hello) hello world from process ID 8985, parent ID 8984 PID PPID COMM 5323 5322 -bash 8984 5323 -bash 8985 8984 ./hello real 0m0.021s user 0m0.003s sys 0m0.004s 19:42:53 -> (time ./hello) hello world from process ID 9000, parent ID 8999 PID PPID COMM 5323 5322 -bash 8999 5323 -bash 9000 8999 ./hello real 0m0.030s user 0m0.003s sys 0m0.005s 19:43:05 ->