From dac1ed2549823b313f99c75696065ad63c8263b1 Mon Sep 17 00:00:00 2001 From: tobhe Date: Mon, 8 Apr 2024 12:48:26 +0000 Subject: [PATCH] Call daemon() only in parent and before proc_exec() to avoid orphaning child processes. Synced from relayd. ok mlarkin@ dv@ --- usr.sbin/vmd/proc.c | 5 ++++- usr.sbin/vmd/vmd.c | 5 +---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/usr.sbin/vmd/proc.c b/usr.sbin/vmd/proc.c index ac6455dd7c7..6b50501873a 100644 --- a/usr.sbin/vmd/proc.c +++ b/usr.sbin/vmd/proc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: proc.c,v 1.23 2024/02/20 21:40:37 dv Exp $ */ +/* $OpenBSD: proc.c,v 1.24 2024/04/08 12:48:26 tobhe Exp $ */ /* * Copyright (c) 2010 - 2016 Reyk Floeter @@ -205,6 +205,9 @@ proc_init(struct privsep *ps, struct privsep_proc *procs, unsigned int nproc, privsep_process = PROC_PARENT; proc_setup(ps, procs, nproc); + if (!debug && daemon(0, 0) == -1) + fatal("failed to daemonize"); + /* * Create the children sockets so we can use them * to distribute the rest of the socketpair()s using diff --git a/usr.sbin/vmd/vmd.c b/usr.sbin/vmd/vmd.c index 887e1cc9bf8..665a6b431b4 100644 --- a/usr.sbin/vmd/vmd.c +++ b/usr.sbin/vmd/vmd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vmd.c,v 1.155 2024/02/05 21:58:09 dv Exp $ */ +/* $OpenBSD: vmd.c,v 1.156 2024/04/08 12:48:26 tobhe Exp $ */ /* * Copyright (c) 2015 Reyk Floeter @@ -947,9 +947,6 @@ main(int argc, char **argv) proc_init(ps, procs, nitems(procs), env->vmd_debug, argc0, argv, proc_id); - if (!env->vmd_debug && daemon(0, 0) == -1) - fatal("can't daemonize"); - if (ps->ps_noaction == 0) log_info("startup"); -- 2.20.1