Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 06 Apr 2026 20:38:47 +0000
From:      bugzilla-noreply@freebsd.org
To:        ports-bugs@FreeBSD.org
Subject:   [Bug 294288] sysutils/alloy: service alloy restart fails with stale pidfile
Message-ID:  <bug-294288-7788@https.bugs.freebsd.org/bugzilla/>

index | next in thread | raw e-mail

https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=294288

            Bug ID: 294288
           Summary: sysutils/alloy: service alloy restart fails with stale
                    pidfile
           Product: Ports & Packages
           Version: Latest
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: Individual Port(s)
          Assignee: ports-bugs@FreeBSD.org
          Reporter: andy@codeedog.com
                CC: zach.leslie@grafana.com
                CC: zach.leslie@grafana.com
             Flags: maintainer-feedback?(zach.leslie@grafana.com)

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.

-- 
You are receiving this mail because:
You are the assignee for the bug.

home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-294288-7788>