I did the following in BASH:
while true;do bash;done
I wrote this one liner, but I was not sure at first whether it:
- stays in the main shell and fathers as many subshells as it runs dry of memory or some other stuff.
- the main shell fathers a subshell, than this subshells fathers a subshell until this lineage runs dry of memory or some other stuff.
But, I suppose it is the second case, because once I run the one liner, I got shortly after my prompt back and I began to type exit and another exit and exit, exit, exit...and I still was not back in the main shell.
Now, since so many subshells have been opened and each one is a program, I thought each one should have its own PID.
So I did:
ps aux | grep bash
expecting to see a lot of processes with bash in their names.
However, nothing like this, there were only two bash shells.
How is it possible, I guess I have somewhere a very wrong idea of processes, shells, subshells and PIDs, but do not know where.