runbg: new helper function inspired by the Infix project

The runbg() function is a delayed execvp() that has double-forked to the
background (to not create zombies).  It is useful for running commands
in the background for APIs that need to return a reply, e.g. a NETCONF
RPC to reboot the system.

Compared to the original in Infix, this version double forks to reparent
itself to PID 1 (init), closes all open files, including stdio.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg committed 2023-09-17 11:00:09 +02:00
1 parent 921afdecb4
commit 92bb0ca399
7 files changed
+135 -3

No files matched your search

+3 -3
View File
@@ -11,12 +11,12 @@ libite_la_SOURCES = chomp.c copyfile.c \
ifconfig.c lfile.c \
makepath.c procval.c progress.c \
pidfile.c pidfilefn.c popenf.c \
reallocarray.c rsync.c strtrim.c \
reallocarray.c rsync.c runbg.c \
strlcpy.c strlcat.c strtonum.c \
strdupa.h strndupa.h strnlen.h \
strmatch.c systemf.c touchf.c \
strmatch.c systemf.c strtrim.c \
telnet.c tempfile.c truncatef.c \
yorn.c which.c \
touchf.c yorn.c which.c \
lite.h strlite.h \
queue.h tree.h