I'm reading a textbook which discusses process group and shell and it says:
Unix shells use the abstraction of a job to represent the processes that are created as a result of evaluating a single command line. At any point in time, there is at most one foreground job and zero or more background jobs. For example, typing
linux> ls | sortcreates a foreground job consisting of two processes connected by a Unix pipe: one running the ls program, the other running the sort program. The shell creates a separate process group for each job.
You can see that the foreground job has process id(pid) process group id(pgid) and they are both 20
My questions are:
Q1-I was told that a process group can be considered as a job, but how come the foreground job in the picture has a process id? as my understanding is, a process is an instance of program in executation, and a process group consists of its member processes, so process group is pretty much an abstraction concept, then how can a concept be an instance of program in executation?
Q2-I was also told that: by convention, the process group ID of a process group equals the process ID of the first member of the process group. so in the picture the pgid of the foreground job should be 21 since the pid of its first member(child process) is 21?