c - For Linux, how can I kill all processes in a session (with same SID) using system calls? -
i trying figure how kill processses in session (with same sid) using system calls c. not interested in kill specific pgid since not processes interested not have same pgid, have same sid.
my research have found this, there graeme made excellent answer scripts: https://unix.stackexchange.com/questions/124127/kill-all-descendant-processes
i pleased answer how possible kill all direct descendant children , more pleased how kill children within session.
or asking possible? not intrested in solution there listing pids of parents descendant.
you can use /proc/ file system query processes (see proc(5) more). in particular can scan /proc/pid/ directories (where pid numerical name 1234, relevant pid, process of pid 1234 described in /proc/1234/ pseudo-directory; hence readdir /proc/ directory , find every numerical name inside it) , check processes have defined parent pid. you'll read sequentially pseudo-files /proc/1234/status (and ppid: line). see this answer , that one.
Comments
Post a Comment