Behavior -------- `service alloy restart` fails intermittently with "already running?" after the stop phase completes. A second restart succeeds. The issue is consistent and reproducible on every first restart attempt after a clean start. To reproduce: `service alloy restart` Observed output: Stopping alloy. Waiting for PIDS: 11317. alloy already running? (pid=11317). A second restart will succeed. The pid file `/var/run/alloy.pid` persists after the alloy process exits. The start phase finds the stale pid file and refuses to start. Environment - FreeBSD 15.0-RELEASE-p2 (amd64) - alloy-1.10.2_8 from pkg - Running inside a VNET jail (reproduces on host as well) Code Analysis ------------- Root Cause The rc.d script (`/usr/local/etc/rc.d/alloy`) is missing the `-f` flag on the `daemon(8)` invocation. Without `-f`, daemon forks the child process, writes the child PID to the pidfile, and exits immediately. No supervisor process remains to clean up the pidfile when the child exits. command_args="-S -T ${name} -p ${pidfile} /usr/bin/env ... Proposed Fix Two changes to `/usr/local/etc/rc.d/alloy`: 1. Add `-f` to `command_args` so daemon stays as supervisor: command_args="-f -S -T ${name} -p ${pidfile} /usr/bin/env ${procname} ${run} \ 2. Add `stop_postcmd` to remove the pidfile after stop: start_precmd=alloy_startprecmd stop_postcmd=alloy_stoppostcmd And add the function: alloy_stoppostcmd() { rm -f ${pidfile} } Testing Tested on FreeBSD 15.0-RELEASE-p2 in a VNET jail. With the fix applied: - `service alloy restart` succeeds on every attempt - Three rapid successive restarts all succeed - `service jail restart` (full jail stop/start cycle) succeeds - daemon supervisor process visible in ps output - pidfile cleaned up after stop Unsure if Bug #292472 is related.
Thank you for the report. I've included the update in the existing PR here. https://github.com/freebsd/freebsd-ports/pull/488