pidofproc: use "pidof -c" to avoid pidofproc results from containers or chroots
authorHarald Dunkel <harald.dunkel@aixigo.de>
Sun, 24 Mar 2019 13:24:13 +0000 (14:24 +0100)
committerDidier Raboud <odyx@debian.org>
Sun, 24 Mar 2019 13:24:30 +0000 (14:24 +0100)
From pidof's manpage:
  -c     Only return process PIDs that are running with the same root
         directory.  This option is ignored for non-root users, as they will
         be unable to check the current root directory of processes they do
         not own.

Closes: #888743
init-functions

index 252da64d24a1648a479bcb546880448ee07856d7..207b2704428e3b3a537a3258682ea3d220b15b4f 100644 (file)
@@ -107,7 +107,7 @@ pidofproc () {
        # pid file doesn't exist, try to find the pid nevertheless
        if [ -x /bin/pidof ] && [ ! "$specified" ]; then
          status="0"
-         /bin/pidof -o %PPID -x $1 || status="$?"
+         /bin/pidof -c -o %PPID -x $1 || status="$?"
          if [ "$status" = 1 ]; then
              return 3 # program is not running
          fi