On Wed, Feb 14, 2018 at 02:33:16PM +0100, Harald Dunkel wrote:
> Hi Reco,
> wrt "pgrep --ns 1 -f /usr/sbin/sshd":
> The executable path simply doesn't tell if this is the right service
> to stop. If I run 2 services in parallel (e.g. for different network
> interfaces), then this approach is already broken. Sample:
> # pgrep --ns 1 -f /usr/sbin/sshd
> 12602
> # ps -ef | grep ssh[d]
> root      12602    1  0 Feb02 ?        00:00:20 /usr/sbin/sshd -D
> # /usr/sbin/sshd -p 2222
> # pgrep --ns 1 -f /usr/sbin/sshd
> 1933
> 12602

True. There's one tiny bit though - try

pidof -o %PPID -x /usr/sbin/sshd

and watch it output several pids as well.
And you don't have to spawn yet another sshd, a simple ssh login will

This particular part of pidofproc does not use pidof to get pid. It uses
pidof to guess the status of the process.

In the case of sshd pidofproc can break in a funny way indeed.

> IMHO pidofproc (and hence the startup scripts) should rely upon not
> loosing important information (the pid file).

True, but that particular part haven't wrote itself, someone did it on


Reply via email to