FreeBSD rc.d script doesn't start as a daemon

Solution 1:

The RC script itself is not intended to daemonize, but is expected to start and stop the daemon.

If your service does not have an option to start as a daemon, you can use daemon(8) to manage that part.

An example:

#!/bin/sh

# PROVIDE: ...
# REQUIRE: ...

. /etc/rc.subr

name="..."

rcvar=${name}_enable
pidfile="/var/run/${name}.pid"
command="/usr/sbin/daemon"
command_args="-c -f -P ${pidfile} -r /usr/local/libexec/${name}"
load_rc_config $name
run_rc_command "$1"