Out of curiosity, I wanted to see what happens when two instances of Bash are launched in parallel, so I ran this Python script:import subprocesssubprocess.Popen([bash])subprocess.Popen([bash])The outcome was quite surprising:user@host$ python test.py[1]+  Stopped                 python test.pyuser@host$ user@host$ exit         <-- Up arrow key pressedThere are stopped jobs.user@host$ exit                    <-- Up arrow key pressed again                                       *Outermost* shell exits!What happened:The Python script was stopped(?)Two Bash prompts were printedI pressed the up arrow keyexit was printed and presumably one (or both?) of the shells exitedI pressed the up arrow key againexit was printed and the outermost shell (the one from which the script was run) exited(!!!), closing the terminalNone of this happens when just a single instance of Bash is run, or when bash is replaced by another program such as ls.What is going on here? I guess it has something to do with the shells stealing each other's standard streams or similar, but I'd really like to understand this in detail.
What happens when two instances of Bash are launched in parallel?
bash;shell;python