When using the following command from an interactive shell:
bash -c 'bash -c "set -m; sleep 123"; echo A' the sleep command does not get its own process group: PID PPID PGRP SID CMD 176134 12953 176134 176134 bash 178061 176134 178061 176134 bash -c 'bash -c "set -m; sleep 123"; echo A' 178062 178061 178061 176134 sleep 123 It seems that the sleep command was exec'ed from the inner bash (being last in the script), which itself is not in its own process group. This does not honour the "set -m" semantics. Putting "echo B" after the sleep command prevents the exec to occur and puts the sleep command into its own process group. 176134 12953 176134 176134 bash 179248 176134 179248 176134 bash -c bash -c "set -m; sleep 123; echo B"; echo A 179249 179248 179248 176134 bash -c set -m; sleep 123; echo B 179250 179249 179250 176134 sleep 123 This looks like an incorrect optimisation in this case (i.e., exec'ing in monitor mode when the shell itself is not alone in its own process group). This is with GNU bash, version 5.1.8(1)-release (x86_64-redhat-linux-gnu), from RHEL 9. -- Daniel Villeneuve