Skip to content
Advertisement

Sudo gets separate PID when starting a command

I do not understand why sudo gets a separate PID (e.g. 1620) while starting dockerd (e.g. 1628) with sudo? To which PID should I send SIGTERM to stop the dockerd?

ps aux | grep dockerd

enter image description here

pstree -ps

enter image description here

Advertisement

Answer

I do not understand why sudo gets a separate PID (e.g. 1620) while starting dockerd (e.g. 1628) with sudo?

It is just the way that sudo works. It runs the command as a child process because it needs to do things after the child process exits.

You may be able to tweak the sudo configs to so that sudo doesn’t fork a child process. On my system, man sudo says:

“If no I/O logging plugins are loaded and the policy plugin has not defined a close() function, set a command timeout or required that the command be run in a new pty, sudo may execute the command directly instead of running it as a child process.”

But notice that :

  • it says may rather than will, and
  • you are necessarily sacrificing some functionality to achieve this “no fork” behavior.

To which PID should I send SIGTERM to stop the dockerd?

You can send signals to the sudo process and they will be relayed to the dockerd process. That’s what man sudo says. Look in the man page’s section on signal handling.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement