qsd: Do not use error_report() before monitor_init

error_report() only works once monitor_init_globals_core() has been
called, which is not the case when parsing the --daemonize option.  Use
fprintf(stderr, ...) instead.

Fixes: 2525edd85f ("qsd: Add --daemonize")
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
Message-Id: <20220609122852.21140-1-hreitz@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
This commit is contained in:
Hanna Reitz 2022-06-09 14:28:52 +02:00
parent 07a64aa47d
commit 1a8fd0e3e7
1 changed files with 5 additions and 1 deletions

View File

@ -296,7 +296,11 @@ static void process_options(int argc, char *argv[], bool pre_init_pass)
}
case OPTION_DAEMONIZE:
if (os_set_daemonize(true) < 0) {
error_report("--daemonize not supported in this build");
/*
* --daemonize is parsed before monitor_init_globals_core(), so
* error_report() does not work yet
*/
fprintf(stderr, "--daemonize not supported in this build\n");
exit(EXIT_FAILURE);
}
break;