I seem to misunderstand the Bash rule for creating a subshell. I thought parentheses always creates a subshell, which runs as its own process.
However, this doesn't seem to be the case. In Code Snippet A (below), the second sleep command does not run in a separate shell (as determined by pstree in another terminal). However, in Code Snippet B, the second sleep command does run in a separate shell. The only difference between the snippets is that the second snippet has two commands within the parentheses.
Could somebody please explain the rule for when subshells are created?
CODE SNIPPET A:
sleep 5
(
sleep 5
)
CODE SNIPPET B:
sleep 5
(
x=1
sleep 5
)