Pidfile ends up in /tmp instead of /var/run [SOLVED]

Morgan Wesström freebsd-questions at
Sun Aug 22 00:51:22 UTC 2010

On 2010-08-22 01:37, Morgan Wesström wrote:
> On 2010-08-22 00:58, Morgan Wesström wrote:
>> I'm trying to create an rc script for the first time following the guide
>> in the handbook. The script works as expected except for the pidfile
>> which is created in /tmp for some reason I can't figure out. The daemon
>> I try to run is a Linux program if that matters. Any help to solve this
>> would be appreciated. Here's the rc script:
>> #!/bin/sh
>> # PROVIDE: linuxdaemon
>> # KEYWORD: shutdown
>> linuxdaemon_enable="${linuxdaemon_enable-NO}"
>> . /etc/rc.subr
>> name="linuxdaemon"
>> rcvar=`set_rcvar`
>> command="/usr/local/bin/linuxdaemon"
>> command_args="-c /usr/local/etc/linuxdaemon.conf > /dev/null 2>&1"
>> load_rc_config $name
>> pidfile="/var/run/"
>> required_files="/usr/local/etc/linuxdaemon.conf"
>> run_rc_command "$1"
> Some additional info. Creating /compat/linux/tmp makes the pidfile move
> there instead when I start the service. Creating /compat/linux/var/run
> does _not_ make the pidfile appear there. I though for a brief moment
> that I had to symlink /compat/linux/var/run to /var/run but that seems
> to be the wrong solution. Still interested in some pointers while I
> continue trying to solve this...
> /Morgan

Being the beginner on rc scripting that I am, I mistakenly believed the
rc subsystem was responsible for creating the pid-file. I understand now
that this is up to the daemon itself and in my case the location of the
pid-file is hardcoded to /tmp in the binary blob. Adjusting the pidfile
entry in the rc script to the pid-files true location solved the problem
and the daemon is no playing nicely with rc.

More information about the freebsd-questions mailing list