Processes of a particular session leader in linux

20 views
Skip to first unread message

a86....@gmail.com

unread,
Feb 6, 2019, 6:37:41 AM2/6/19
to psutil
Hi,

I need in linux all the processes from of a particular session leader. With ps command I do:

ps -o pid,%cpu,%mem,user,command -g <pid_session_leader>

How could I get it using psutil?

Thanks and best regards

Giampaolo Rodola'

unread,
Feb 6, 2019, 8:17:38 AM2/6/19
to psu...@googlegroups.com
What is a session leader? The user who owns the process? You may wanna check username() and uids() methods of the Process class.

--
You received this message because you are subscribed to the "Python process utilities (psutil)" project group:
http://code.google.com/p/psutil
To post to this group, send email to psu...@googlegroups.com
To unsubscribe from this group, send email to psutil-un...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/psutil
---
You received this message because you are subscribed to the Google Groups "psutil" group.
To unsubscribe from this group and stop receiving emails from it, send an email to psutil+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--

a86....@gmail.com

unread,
Feb 8, 2019, 5:41:19 AM2/8/19
to psutil
Hi,

On linux, 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(). A session leader is the process which has the state 's', example:

user1 46080  0.0  0.0 131264  3660 pts/1    Ss   feb05   0:01 -bash

Anyway I got it through ps command.

Thanks for your help.

Regards
Reply all
Reply to author
Forward
0 new messages