Skip to content
Snippets Groups Projects
Commit f22ac472 authored by Hanna Reitz's avatar Hanna Reitz Committed by Kevin Wolf
Browse files

os-posix: Add os_set_daemonize()


The daemonizing functions in os-posix (os_daemonize() and
os_setup_post()) only daemonize the process if the static `daemonize`
variable is set.  Right now, it can only be set by os_parse_cmd_args().

In order to use os_daemonize() and os_setup_post() from the storage
daemon to have it be daemonized, we need some other way to set this
`daemonize` variable, because I would rather not tap into the system
emulator's arg-parsing code.  Therefore, this patch adds an
os_set_daemonize() function, which will return an error on os-win32
(because daemonizing is not supported there).

Signed-off-by: default avatarHanna Reitz <hreitz@redhat.com>
Message-Id: <20220303164814.284974-2-hreitz@redhat.com>
Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
parent d5d2b15e
No related branches found
No related tags found
No related merge requests found
......@@ -55,6 +55,7 @@ int os_mlock(void);
typedef struct timeval qemu_timeval;
#define qemu_gettimeofday(tp) gettimeofday(tp, NULL)
int os_set_daemonize(bool d);
bool is_daemonized(void);
/**
......
......@@ -77,6 +77,14 @@ typedef struct {
} qemu_timeval;
int qemu_gettimeofday(qemu_timeval *tp);
static inline int os_set_daemonize(bool d)
{
if (d) {
return -ENOTSUP;
}
return 0;
}
static inline bool is_daemonized(void)
{
return false;
......
......@@ -317,6 +317,12 @@ bool is_daemonized(void)
return daemonize;
}
int os_set_daemonize(bool d)
{
daemonize = d;
return 0;
}
int os_mlock(void)
{
#ifdef HAVE_MLOCKALL
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment