Bug 278342 - daemon(8): -R doesn't restart supervised process
Summary: daemon(8): -R doesn't restart supervised process
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 14.0-RELEASE
Hardware: Any Any
: --- Affects Only Me
Assignee: Kyle Evans
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-04-13 05:44 UTC by sigsys
Modified: 2024-04-17 05:51 UTC (History)
6 users (show)

See Also:
kevans: mfc-stable14+
kevans: mfc-stable13+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description sigsys 2024-04-13 05:44:19 UTC
When certain other options are also specified it might work correctly, but with -R alone, "supervise mode" doesn't kick in. Using -R alone used to work on previous versions.

diff --git i/usr.sbin/daemon/daemon.c w/usr.sbin/daemon/daemon.c
index da8e4895e19b..52fbfca1dcd2 100644
--- i/usr.sbin/daemon/daemon.c
+++ w/usr.sbin/daemon/daemon.c
@@ -240,12 +240,13 @@ main(int argc, char *argv[])
 		case 'R':
 			state.restart_enabled = true;
 			state.restart_delay = strtol(optarg, &p, 0);
 			if (p == optarg || state.restart_delay < 1) {
 				errx(6, "invalid restart delay");
 			}
+			state.mode = MODE_SUPERVISE;
 			break;
 		case 's':
 			state.syslog_priority = get_log_mapping(optarg,
 			    prioritynames);
 			if (state.syslog_priority == -1) {
 				errx(4, "unrecognized syslog priority");
Comment 1 Kyle Evans freebsd_committer freebsd_triage 2024-04-13 14:50:04 UTC
LGTM (will commit later this evening, ~6-8 hours, if nobody else beats me to it)
Comment 2 commit-hook freebsd_committer freebsd_triage 2024-04-14 03:13:32 UTC
A commit in branch main references this bug:

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

commit bbc6e6c5ec8c7938b98a36899fa083aa7ce4724e
Author:     Mathieu <sigsys@gmail.com>
AuthorDate: 2024-04-14 03:10:06 +0000
Commit:     Kyle Evans <kevans@FreeBSD.org>
CommitDate: 2024-04-14 03:12:36 +0000

    daemon: fix -R to enable supervision mode

    If we're doing restarts, then we must supervise -- the 'R' case simply
    got missed.

    PR:     278342
    Fixes:  f907027b49d ("daemon: set supervise_enabled during [..]")

 usr.sbin/daemon/daemon.c | 1 +
 1 file changed, 1 insertion(+)
Comment 3 Kyle Evans freebsd_committer freebsd_triage 2024-04-14 03:14:48 UTC
MFC'ing this to stable/13 and stable/14, but not shooting for an EN since it's a relatively minor issue that has a clear workaround w/o side effect (specify -r as well).
Comment 4 commit-hook freebsd_committer freebsd_triage 2024-04-17 05:49:02 UTC
A commit in branch stable/14 references this bug:

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

commit a871d0f13c56f6ea2ec86ed8175634b562de514a
Author:     Mathieu <sigsys@gmail.com>
AuthorDate: 2024-04-14 03:10:06 +0000
Commit:     Kyle Evans <kevans@FreeBSD.org>
CommitDate: 2024-04-17 05:48:26 +0000

    daemon: fix -R to enable supervision mode

    If we're doing restarts, then we must supervise -- the 'R' case simply
    got missed.

    PR:     278342
    Fixes:  f907027b49d ("daemon: set supervise_enabled during [..]")
    (cherry picked from commit bbc6e6c5ec8c7938b98a36899fa083aa7ce4724e)

 usr.sbin/daemon/daemon.c | 1 +
 1 file changed, 1 insertion(+)
Comment 5 commit-hook freebsd_committer freebsd_triage 2024-04-17 05:51:05 UTC
A commit in branch stable/13 references this bug:

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

commit 1e2be096d4252308db35b0424bd408c2b8aa5990
Author:     Mathieu <sigsys@gmail.com>
AuthorDate: 2024-04-14 03:10:06 +0000
Commit:     Kyle Evans <kevans@FreeBSD.org>
CommitDate: 2024-04-17 05:50:03 +0000

    daemon: fix -R to enable supervision mode

    If we're doing restarts, then we must supervise -- the 'R' case simply
    got missed.

    PR:     278342
    Fixes:  f907027b49d ("daemon: set supervise_enabled during [..]")
    (cherry picked from commit bbc6e6c5ec8c7938b98a36899fa083aa7ce4724e)

 usr.sbin/daemon/daemon.c | 1 +
 1 file changed, 1 insertion(+)
Comment 6 Kyle Evans freebsd_committer freebsd_triage 2024-04-17 05:51:46 UTC
Thanks for the report!