1
0
mirror of https://github.com/openbsd/src.git synced 2025-01-10 06:47:55 -08:00

Call daemon() only in parent and before proc_exec() to avoid orphaning child

processes. Synced from relayd.

ok florian@
This commit is contained in:
tobhe 2024-04-08 13:18:54 +00:00
parent 2a1b622220
commit 28fef5effa
2 changed files with 5 additions and 4 deletions

View File

@ -1,4 +1,4 @@
/* $OpenBSD: proc.c,v 1.30 2024/01/16 13:33:12 claudio Exp $ */
/* $OpenBSD: proc.c,v 1.31 2024/04/08 13:18:54 tobhe Exp $ */
/*
* Copyright (c) 2010 - 2016 Reyk Floeter <reyk@openbsd.org>
@ -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

View File

@ -1,4 +1,4 @@
/* $OpenBSD: snmpd.c,v 1.50 2023/12/22 13:04:30 martijn Exp $ */
/* $OpenBSD: snmpd.c,v 1.51 2024/04/08 13:18:54 tobhe Exp $ */
/*
* Copyright (c) 2007, 2008, 2012 Reyk Floeter <reyk@openbsd.org>
@ -222,8 +222,6 @@ main(int argc, char *argv[])
env->sc_engine_boots = 0;
proc_init(ps, procs, nitems(procs), debug, argc0, argv0, proc_id);
if (!debug && daemon(0, 0) == -1)
err(1, "failed to daemonize");
log_procinit("parent");
log_info("startup");