I understand that when I run exit
it terminates my current shell because exit
command run in the same shell. I also understand that when I run exit &
then original shell will not terminate because &
ensures that the command is run in sub-shell resulting that exit
will terminate this sub-shell and return back to original shell. But what I do not understand is why commands with and without &
looks exactly the same under pstree
, in this case sleep 10
and sleep 10 &
. 4669 is the PID of bash under which first sleep 10
and then sleep 10 &
were issued and following output was obtained from another shell instance during this time:
# version without &
$ pstree 4669
bash(4669)───sleep(6345)
# version with &
$ pstree 4669
bash(4669)───sleep(6364)
Should’t the version with &
contain one more spawned sub-shell (e.g. in this case with PID 5555), like this one?
bash(4669)───bash(5555)───sleep(6364)
PS: Following code was omitted from output of pstree
beginning for better readability:
systemd(1)───slim(1009)───ck-launch-sessi(1370)───openbox(1551)───/usr/bin/termin(4510)───bash(4518)───screen(4667)───screen(4668)───