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?

  • 2
    After fork() the child process is in the same group as the parent. The child can set itself to a new group (perhaps before exec()-ing something else), or it can stay within the parent's group. It all depends on what you want to achieve. Nov 7, 2017 at 13:52
  • @Satō Katsura So in my case, cat has set itself to a new group?
    – user259392
    Nov 7, 2017 at 13:55
  • 3
    No, bash did a fork(), then the child set itself to a new group, then the same child exec()-ed your cat. Nov 7, 2017 at 14:10
  • 1
    Shells do this as part of job handling -- unix.stackexchange.com/questions/363126/…
    – thrig
    Nov 7, 2017 at 15:41


You must log in to answer this question.

Browse other questions tagged .