Re: Job vs process?



In article
<17c23f9b-0ad5-4c8f-b08b-80e44d335fbe@xxxxxxxxxxxxxxxxxxxxxxxxxxx>,
dspfun <dspfun@xxxxxxxxxxx> wrote:

So what is the defintion of a job? A job is a process, but a process
is not necessarily a job.

Could this be a correct definition:
Any command run by a user on the shell command line is a job?

A job is the set of processes that were spawned to implement a single
command line.  E.g. when you run a pipeline, the job consists of all the
processes in the pipeline:

tail foo | grep bar

Creates a job containing the tail and grep processes.


Thanks for the definition. I would like to add the following to the
definition as well, do you agree?:

A job is _always_ started from an interactive shell and a job is
_always_ connected to a controlling terminal (tty). The controlling
terminal is by default connected in three ways to your (or any) job:
via the three standard file streams, stdin, stdout, and stderr. The
operating system takes care of connecting these three standard file
streams to the job.

Jobs don't connect to file descriptors, processes do. The first command
in a pipeline simply inherits the shell's stdin, and the last command
inherits the shell's stdout and stderr. This happens regardless of
whether job control is in use.

The controlling terminal is the one from which you interactively can
send signals to the job.

Right. When the shell creates a foreground job, it sets the controlling
terminal's process group to the one running that job.

--
Barry Margolin, barmar@xxxxxxxxxxxx
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***
.


Quantcast