Sample Header Ad - 728x90

Why does sudo change process session id using setsid()?

0 votes
0 answers
47 views
I've been writing a script that spawns a child process as a different user via sudo then I realized that my script is not getting SIGINT as opposed to when I run it without sudo. As suspected strace shows that [sudo](https://man7.org/linux/man-pages/man8/sudo.8.html) calls [setsid](https://www.man7.org/linux/man-pages/man2/setsid.2.html) after [clone](https://man7.org/linux/man-pages/man2/clone.2.html) which means my (python) scripts are in a different process-group and don't receive the same signals as the sudo process. What would be the reason sudo calls setsid? Is there security benefit? Why isn't there an equivalent of su --session-command option to disable this behavior (which is also discouraged according to man page)?
Asked by Ahmet Sait (101 rep)
Jan 3, 2025, 08:45 PM