What does it mean to “start a process in its own process group”? The shell starts processes in its process groups, since it performs job management (having a group of processes for processes in the foreground and several process groups for each pipeline running in the background).
To make sure that the shell starts a new process group for each pipeline, you can do this:
ps fax -o pid,pgid,cmd | less
which will show something like:
11816 11816 | \_ /bin/bash 4759 4759 | \_ ps fax -o pid,pgid,cmd 4760 4759 | \_ less
Notice that the shell has created a new process group for the pipeline, and each process in the pipeline shares a process group.
Edit:
I think I know what you're driving at. You call system from Perl. Apparently, sh -c does not create new process groups, since it is a shell without job control.
What I would do would be fork , and then on the child:
setpgrp; system("ps fax -o pid,pgid,cmd");
and wait for the parent.
source share