- Why do you have to call setpgid() when a process is supposed to run in the background?
When you create a process, it by default is created in a process group from which it was created ... When you run a command from the shell, the new process is created in that group ... and this group has a controlling tty ... obviously for backgrounding a process you need to disassociate from the controlling tty .... thus need for changing the process group
You create a separate group for the current process in which it will be the only process ... If setpgid creates groups if they do not exist, it will work like a charm
return to top