Process Terminology – Difference Between a Job and a Process
job-controlprocessterminology
What is the difference between a "job" and a "process"?
Best Answer
A process is any running program with its own address space.
A job is a concept used by the shell - any program you interactively start that doesn't detach (ie, not a daemon) is a job. If you're running an interactive program, you can press CtrlZ to suspend it. Then you can start it back in the foreground (using fg) or in the background (using bg).
While the program is suspended or running in the background, you can start another program - you would then have two jobs running. You can also start a program running in the background by appending an "&" like this: program &. That program would become a background job. To list all the jobs you are running, you can use jobs.
For more information on jobs, see this section of the bash man page.
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 killsystem 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.
top is mostly used interactively (try reading man page or pressing "h" while top is running) and ps is designed for non-interactive use (scripts, extracting some information with shell pipelines etc.)
Best Answer
A process is any running program with its own address space.
A job is a concept used by the shell - any program you interactively start that doesn't detach (ie, not a daemon) is a job. If you're running an interactive program, you can press CtrlZ to suspend it. Then you can start it back in the foreground (using
fg
) or in the background (usingbg
).While the program is suspended or running in the background, you can start another program - you would then have two jobs running. You can also start a program running in the background by appending an "&" like this:
program &
. That program would become a background job. To list all the jobs you are running, you can usejobs
.For more information on jobs, see this section of the bash man page.