This Time Self-Hosted
dark mode light mode Search

Providing a working pidof command

So, I already blogged time ago (if I remember correctly) about the need for a pidof command on Gentoo/FreeBSD to go with a newer baselayout. I found this version, but I had to patch it quite a bit, I also sent the patches upstream but after an initial discussion, I got no response and no new releases were due.

So what’s the problem? That pidof patched as it is in Gentoo/FreeBSD is just a workaround, we can’t continue with it as it might be unreliable, and probably will need some changes to work on other BSD platforms (thing that we actually need), so I’m thinking of taking that code and writing a new pidof from it.

What’s the problem then? novel’s pidof is released under BSD license, as almost every tool that is used in BSD core system, but I’m pondering about changing the license over GPL. From one side, using BSD it would still be a classic tool for BSD platforms, from the other, by using GPL I can use gnulib’s porting facilities (if we end up in an operating system needing more of that), and I can also reuse code from sysvinit’s pidof command (that is GPL-licensed).

I’ll let you know later today what I decided to do about it, and I’ll also provide a bzr repository where to take the code of the new version from at that point.. bzr is useful because I can use it directly on my dev space so that it’s available for users too, so thunder, arachnist, reb and bbj can access it and tell me if it works on their operating systems 😛

Comments 4
  1. As the page you linked to says,”The pgrep(1) utility appaired in FreebSD 5.3 provides the same features and is much more powerful than pidof, so you might consider using it instead.”What is ‘pidof’ needed for specifically that pgrep won’t provide (maybe on Linux _and_ FreeBSD)?

  2. Ah, thanks.Just playing around with pgrep, I presume it’s just looking anywhere in the process name for a matching string, e.g. with “/bin/sh ./x.sh” in the process list:$ pgrep x.sh17895$ pidof x.sh[no output]Is that sufficient for what rc-daemon.sh needs?Sorry for the questions, just trying to get my head around it. 🙂

  3. The -x option (mainly an “hack”), that allows to find pids of shells and interpreters running a given script. It’s necessary for rc-daemon.sh script to behave correctly.

  4. It isn’t. This way it looks for everything, also if you have an editor open with that file between it or a shell running “misterx.sh“.Also, pgrep is not available in the first stages of boot as it’s in /usr.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.