Process, process group, and (process group) session are concepts of Linux.

If I am correct, in a bash shell, the process groups started in it are called jobs.

Do all the jobs started in a bash shell exactly form a session? "Exactly" means no more and no less.


1 Answer 1


Not every shell process, only a login shell creates a new session (more details below). At the start the session has obviously only one member, the shell itself. Each newly forked process belongs automatically to the same session. A process may remove itself from its session by creating a new one with setsid(). There is no other way for a process to change its session.


session members = login shell
    AND all child processes (and their child processes, etc.)
    EXCEPT child processes that have created its own sessions

A remaining question is if all processes spawned by the shell are always started as "jobs", i.e. one process group per command. While this is normally true, I do not know for sure for non-interactive shells.


This question was about bash, but the same can be said about other similar command line oriented shells with job control.

As @StéphaneChazelas pointed out, a session is created by the program that manages logins at a terminal or pseudoterminal device. A session is strictly tied with its terminal.

The user must log in first, only then his or her shell program can be determined from the corresponding record in the passwd file. That shell program gets execed - PID remains the same. A session is thus created inside a process which becomes the user's login shell.

  • 1
    sessions are not created by login shells. You terminal emulator, sshd/telnetd/rlogind or getty typically create sessions. Usually, those typically execute a shell in the process where they did a setsid() but they don't have to, nor are the shells they start always invoked as login shells. Graphical session managers, some init systems typically also create sessions, and generally don't make shells the session leaders. Aug 14, 2017 at 17:20
  • @StéphaneChazelas Thank you for adding these details. I have used the term login shell for the process (one PID) that becomes the login shell. This is an oversimplification. I will edit my answer later.
    – VPfB
    Aug 14, 2017 at 21:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .