Ubuntu: Is it “bash” that changes the foreground process group of a terminal?



Question:

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, is it bash that changed it?


Solution:1

Yes. Quoting this answer by Gilles on U&L:

The terminal's associated PGID can be set by the tcsetpgrp function, which is called by the shell when it starts an external program in the foreground, or moves a job into the foreground with fg.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »