Arch Linux

Please read this before reporting a bug:
https://wiki.archlinux.org/title/Bug_reporting_guidelines

Do NOT report bugs when a package is just outdated, or it is in the AUR. Use the 'flag out of date' link on the package page, or the Mailing List.

REPEAT: Do NOT report bugs for outdated packages!
Tasklist

FS#14428 - [sysvinit-2.86] pidof ignores full pathname (pidof /usr/bin/daemon1 == pidof daemon1)

Attached to Project: Arch Linux
Opened by Sebastian (sepo) - Wednesday, 22 April 2009, 15:38 GMT
Last edited by Eric Belanger (Snowman) - Wednesday, 06 May 2009, 18:36 GMT
Task Type Bug Report
Category Packages: Core
Status Closed
Assigned To Eric Belanger (Snowman)
Architecture All
Severity Critical
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 1
Private No

Details

Description:

pidof ignores the full pathname even if the manpage says it doesn't.
Since pidof is used in many rc.d scripts this may lead to unwanted misbehavior.

PIDOF(8)
[...]
When pidof is invoked with a full pathname to the program it should find the pid of, it is reasonably safe. Otherwise it is possible
that it returns pids of running programs that happen to have the same name as the program you're after but are actually other programs.
[...]

Additional info:
package version : sysvinit-2.86
debian bug report: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=160329

Steps to reproduce:

$ /usr/sbin/daemon1
$ /home/user/daemon1
$ ./daemon1

$ pidof /usr/sbin/daemon1
-> prints the 3 pids of the above programs, but only /usr/sbin/daemon1 should match
This task depends upon

Closed by  Eric Belanger (Snowman)
Wednesday, 06 May 2009, 18:36 GMT
Reason for closing:  Fixed
Comment by Sebastian (sepo) - Wednesday, 22 April 2009, 15:40 GMT
This is not an Arch Linux bug, but since pidof is bugged Arch Linux should not use it with full pathnames in rc.d scripts.
Comment by Eric Belanger (Snowman) - Wednesday, 22 April 2009, 19:03 GMT
sysvinit's source haven't been updated in a while. I don't think it would hurt applying Debian's patch to fix this. At least much easier than to find/fix all the potentially incorrect daemon scripts.
Comment by Gerardo Exequiel Pozzi (djgera) - Saturday, 25 April 2009, 01:41 GMT
The "pidof" is a symlink to "/sbin/killall5" from sysvinit.

There is a package "core/psmisc" that includes a "killall", this can work as "pidof" and works better.

The problem is that "killall" are in /usr/bin/ and killall5 in /sbin so, if /usr is in another partition and there are a problem in it...

@Sebastian: try this:
ln -sf /usr/bin/killall /bin/pidof

To restore:
ln -sf ../sbin/killall5 /bin/pidof

For example:
This is with pidof (kilall5) from sysvinit
[djgera@exequiel ~]$ pidof /lalala/agetty
2048 2047 2046 2045 2044

And this with pidof (killall) from psmisc
$ pidof /lalala/agetty
/lalala/agetty: No such file or directory


Comment by Sebastian (sepo) - Saturday, 25 April 2009, 08:18 GMT
Thank you Gerardo, that works.

Nevertheless the sysvini package should be fixed that there is a properly working pidof e.g. after system installation.
Comment by Sebastian (sepo) - Saturday, 25 April 2009, 08:45 GMT
I just notice that pidof linked to /usr/bin/killall does not support shell scripts. It even doesn't print the pid of the interpreter.
Comment by Sebastian (sepo) - Saturday, 25 April 2009, 11:50 GMT
Linking /usr/bin/killall to /bin/pidof leads to an unbootable system.
Comment by Gerardo Exequiel Pozzi (djgera) - Tuesday, 28 April 2009, 01:10 GMT
maybe you tried to say /bin/pidof -> /usr/bin/killall and not /usr/bin/killall -> /bin/pidof ?
Comment by Sebastian (sepo) - Tuesday, 28 April 2009, 08:55 GMT
What i did is: ln -sf /usr/bin/killall /bin/pidof

I just verified it once again.
If /usr/bin/myscript is a schell script

$ pidof myscript # works, prints the pid
$ pidof /usr/bin/myscript # doesn't work, no pid (the -x option does not exist)

If i reboot with /bin/pidof still linked to /usr/bin/killall i get an error at "Loading standard ACPI modules" (pidof useage is printed) and at "Checking Filesystems" ("/sbin/fsck.xfs: UUID=[...] does not exist" & "Filesystem Check Failed"). Then the bootup scripts are stopping after "Checking Filesystems" and i get a console prompt "Give root password for maintenance".
Comment by Eric Belanger (Snowman) - Wednesday, 29 April 2009, 23:41 GMT
pidof seems to work fine here:

$ ps aux |grep emacs
eric 14236 0.1 0.5 139024 20936 pts/2 S 19:28 0:00 emacs ChangeLog
eric 15317 5.2 0.5 139052 20748 pts/4 S+ 19:41 0:00 ./emacs
eric 25032 0.0 0.5 140408 22380 pts/1 S 19:04 0:00 emacs PKGBUILD
eric 25610 0.1 0.5 140728 22724 pts/2 S 19:10 0:02 emacs PKGBUILD
$ pidof emacs
25610 25032 15317 14236
$ pidof /usr/bin/emacs
25610 25032 14236
$ pidof /home/eric/emacs
15317
Comment by Gerardo Exequiel Pozzi (djgera) - Wednesday, 29 April 2009, 23:53 GMT
well, the documentation says that this behaviour is expected. In the citation of original message:

..."Otherwise it is possible that it returns pids of running programs that happen to have the same name as the program you're after but are actually other programs."

$ /bin/sleep 60 &
[1] 9683
$ pidof /no-existe/sleep
9683

Comment by Eric Belanger (Snowman) - Thursday, 30 April 2009, 00:19 GMT
OK, I see. I'll check the Debian patch.
Comment by Eric Belanger (Snowman) - Friday, 01 May 2009, 02:48 GMT
sysvinit-2.86-5 is in testing. Please test and report how it goes.
Comment by Sebastian (sepo) - Saturday, 02 May 2009, 16:37 GMT
Thank you, this fixes my problem explained above.

Loading...