Linux – session leader in `ps ax`

bashlinuxprocessunix

See the command bellow

# ps ax | grep bitlbee
 2271 ?        Ss     0:00 /usr/bin/bitlbee -s mysql -c /root/config.conf
 3930 ?        S      0:00 /usr/bin/bitlbee -s mysql -c /root/config.conf

See the STAT column. Here is the explanation

S    Interruptible sleep (waiting for an event to complete)
s    is a session leader

What is session leader here? Also what is session here? How do I know which of these 2 process is active?

Best Answer

From The Linux Kernel: Processes:

10.3 Sessions

Every process group is in a unique session. (When the process is created, it becomes a member of the session of its parent.) By convention, the session ID of a session equals the process ID of the first member of the session, called the session leader. A process finds the ID of its session using the system call getsid().

Every session may have a controlling tty, that then also is called the controlling tty of each of its member processes. A file descriptor for the controlling tty is obtained by opening /dev/tty. (And when that fails, there was no controlling tty.) Given a file descriptor for the controlling tty, one may obtain the SID using tcgetsid(fd).

As to your last question

How do I know which of these 2 process is active?

Given that both processes are sleeping, the answer is "neither".