Let's say I have opened a terminal window that uses bash
. The process group that bash
belongs to is the foreground process group of the terminal.
Now let's say I opened cat
in the terminal, what will happen is that a new process group will be created and cat
will belong to this process group, and this process group will now become the foreground process group of the terminal.
When cat
terminates and execution returns to bash
, the process group that bash
belongs to will again becomes the foreground process group of the terminal.
My question is: how did the foreground process group of the terminal changed in these two times, who changed it?