I always thought that a child process will be in the same process group as the parent process. But I have read the following from here:
if you run some_app from the shell, the shell creates a new process group for it, and makes that the foreground process group of the session.
I made bash
execute cat
, and I found out that cat
indeed has a different process group id than bash
. Is this a bash
only behavior to have the child process be in a different group?
fork()
the child process is in the same group as the parent. The child can set itself to a new group (perhaps beforeexec()
-ing something else), or it can stay within the parent's group. It all depends on what you want to achieve.cat
has set itself to a new group?bash
did afork()
, then the child set itself to a new group, then the same childexec()
-ed yourcat
.