Pidfile generated by /usr/sbin/daemon not usable by rc.d script
Ian Smith
smithi at nimnet.asn.au
Thu May 26 10:10:26 UTC 2016
In freebsd-questions Digest, Vol 625, Issue 4, Message: 19
On Wed, 25 May 2016 20:26:56 +0100 RW <rwmaillists at googlemail.com> wrote:
> On Wed, 25 May 2016 17:12:36 +0200
> Adam Lindberg wrote:
>
> > Hi,
> >
> > I don?t know what powerd is and how it factors into this. :-)
>
> It's an example of a daemon that generates a pid file without a
> newline, and yet "stop" and "status" work.
>
> It turns out that /etc/rc.d/powerd doesn't define pidfile, in which
> case rc.subr finds the pid from the output of ps. So it's not a
> counter-example and it does appear to be a bug that rc.subr can't cope
> with a pid file without a newline.
>
> You could use the same method, but using sed seems safer.
Just as another data point, from a 9.3 system (if relevant), where the
majority of pidfiles have no trailing newline; no obvious consistency:
root at x200:~ # sh -c 'for i in /var/run/*.pid ; do echo $i; hd $i; done'
/var/run/consolekit.pid
00000000 39 31 31 0a |911.|
00000004
/var/run/cron.pid
00000000 38 35 31 |851|
00000003
/var/run/devd.pid
00000000 34 32 37 |427|
00000003
/var/run/dhclient.em0.pid
00000000 33 34 38 |348|
00000003
/var/run/moused.pid
00000000 37 31 39 |719|
00000003
/var/run/ntpd.pid
00000000 36 39 32 |692|
00000003
/var/run/powerd.pid
00000000 36 39 35 |695|
00000003
/var/run/sendmail.pid
00000000 38 32 34 0a 2f 75 73 72 2f 73 62 69 6e 2f 73 65 |824./usr/sbin/se|
00000010 6e 64 6d 61 69 6c 20 2d 4c 20 73 6d 2d 6d 74 61 |ndmail -L sm-mta|
00000020 20 2d 62 64 20 2d 71 33 30 6d 20 2d 4f 44 61 65 | -bd -q30m -ODae|
00000030 6d 6f 6e 50 6f 72 74 4f 70 74 69 6f 6e 73 3d 41 |monPortOptions=A|
00000040 64 64 72 3d 6c 6f 63 61 6c 68 6f 73 74 0a |ddr=localhost.|
0000004e
/var/run/sshd.pid
00000000 38 30 31 0a |801.|
00000004
/var/run/syslog.pid
00000000 35 39 30 |590|
00000003
check_pidfile in /etc/rc.subr (at 9.3 and in head I see) uses:
read _pid _junk < $_pidfile
which extracts pids ok with or without the newline. Don't suppose the
behaviour of read in sh(1) might have changed in terms of separating
words or in whitespace reckoning? Otherwise this is rather mysterious.
cheers, Ian
More information about the freebsd-questions
mailing list