What’s the difference between a process group and a job? If I type pr * | lpr then is it both a process group as well a job?
What exactly is the difference between a process group ID and a job ID?
Edit: I know it appears similar to What is the difference between a job and a process?, but it is slightly different. Also, I didn’t understand this concept from this thread.
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
A process group is a unix kernel concept. It doesn’t come up very often. You can send a signal to all the processes in a group, by calling the kill system call or utility with a negative argument.
When a process is created (with fork), it remains in the same process group as its parent. A process can move into another group by calling setpgid or setpgrp. This is normally performed by the shell when it starts an external process, before it executes execve to load the external program.
The main use for process groups is that when you press Ctrl+C, Ctrl+Z or Ctrl+ to kill or suspend programs in a terminal, the terminal sends a signal to a whole process group, the foreground process group. The details are fairly complex and mostly of interest to shell or kernel implementers; the General Terminal Interface chapter of the POSIX standard is a good presentation (you do need some unix programming background).
Jobs are an internal concept to the shell. In the simple cases, each job in a shell corresponds to a process group in the kernel.
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0