git: a70ca1ebd8ad - main - rc.subr: svcj - remove the service jail when the service is not running

From: Alexander Leidinger <netchild_at_FreeBSD.org>
Date: Sun, 30 Aug 2026 17:43:50 UTC
The branch main has been updated by netchild:

URL: https://cgit.FreeBSD.org/src/commit/?id=a70ca1ebd8add7ea99b5674de715ae5fbf389dce

commit a70ca1ebd8add7ea99b5674de715ae5fbf389dce
Author:     Alexander Leidinger <netchild@FreeBSD.org>
AuthorDate: 2026-08-30 09:44:57 +0000
Commit:     Alexander Leidinger <netchild@FreeBSD.org>
CommitDate: 2026-08-30 17:43:06 +0000

    rc.subr: svcj - remove the service jail when the service is not running
    
    A service whose tracked process had died while another process of its own
    kept the jail alive, therefore left svcj-${name} behind, and the next start
    would fail.
    
    Fixes:                  2efbd480f1d3 rc: add service jails framework
    MFC after:              1 week
    MFC to:                 stable/15
    Assisted-by:    Claude Code (Opus 5)
---
 libexec/rc/rc.subr | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/libexec/rc/rc.subr b/libexec/rc/rc.subr
index 9b72bd5e9c7b..d919e2d25916 100644
--- a/libexec/rc/rc.subr
+++ b/libexec/rc/rc.subr
@@ -1584,6 +1584,10 @@ $command $rc_flags $command_args"
 
 		stop)
 			if [ -z "$rc_pid" ]; then
+				if checkyesno ${name}_svcj &&
+				    /usr/sbin/jls -j svcj-${name} jid >/dev/null 2>&1; then
+					$JAIL_CMD -r svcj-${name} 2>/dev/null
+				fi
 				[ -n "$rc_fast" ] && return 0
 				_run_rc_notrunning
 				return 1