Files
systemd/src/shared/fork-notify.h
T
Kai Lüke 4dbcc319ca fork-notify: Use callback instead of argv NULL code path with return
In 012d87c1fc/cc8f398202 it was made possible for fork_notify() to
return in the child but at that point all FDs were closed and the
_cleanup path from the return causes assertion failures due to invalid
FDs in notify_event_source/event, leading to a vmspawn failing to start
with a SIGABRT logged in coredump.
Instead of TAKE_PTR on a bunch of things which is fragile, rather avoid
the return and instead add an explicit callback handler and guarantee
to exit directly after it. A userdata argument is also added but not
used yet I think it's quite normal to have for a callback.
2026-04-27 22:14:05 +09:00

25 lines
791 B
C

/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include "output-mode.h"
#include "shared-forward.h"
typedef void (*fork_notify_handler_t)(void *userdata);
int fork_notify(char * const *argv, fork_notify_handler_t child_handler, void *child_userdata, PidRef *ret_pidref);
void fork_notify_terminate(PidRef *pidref);
void fork_notify_terminate_many(sd_event_source **array, size_t n);
int journal_fork(RuntimeScope scope, char * const *units, OutputMode output, PidRef *ret_pidref);
int fork_journal_remote(
const char *listen_address,
const char *output,
uint64_t max_use,
uint64_t keep_free,
uint64_t max_file_size,
uint64_t max_files,
PidRef *ret_pidref);