简体   繁体   中英

Sudo gets separate PID when starting a command

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

ps aux | grep dockerd

在此处输入图像描述

pstree -ps

在此处输入图像描述

I do not understand why sudo gets a separate PID (eg 1620) while starting dockerd (eg 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM