diff options
author | Lennart Poettering <lennart@poettering.net> | 2021-10-20 13:14:11 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2021-10-22 16:34:30 +0200 |
commit | 8ddefb8eef412f888b230588ebde832fc50dc781 (patch) | |
tree | 86937d0c715afe03295cc6a10d1cdd447475074f /src/basic/process-util.c | |
parent | 197aec7e79d2f61c50b1684317c11d36968a83f2 (diff) | |
download | systemd-8ddefb8eef412f888b230588ebde832fc50dc781.tar.gz |
basic: move freeze() from shared/exec-util.h to basic/process-util.h
That way we can use it in other code from basic/. It fits into both
headers equally well or badly, hence let's just move this one function.
Diffstat (limited to 'src/basic/process-util.c')
-rw-r--r-- | src/basic/process-util.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/basic/process-util.c b/src/basic/process-util.c index 5e7ed06ea5..fce96dd5eb 100644 --- a/src/basic/process-util.c +++ b/src/basic/process-util.c @@ -1618,6 +1618,27 @@ bool invoked_as(char *argv[], const char *token) { return strstr(last_path_component(argv[0]), token); } +_noreturn_ void freeze(void) { + log_close(); + + /* Make sure nobody waits for us on a socket anymore */ + (void) close_all_fds_full(NULL, 0, false); + + sync(); + + /* Let's not freeze right away, but keep reaping zombies. */ + for (;;) { + siginfo_t si = {}; + + if (waitid(P_ALL, 0, &si, WEXITED) < 0 && errno != EINTR) + break; + } + + /* waitid() failed with an unexpected error, things are really borked. Freeze now! */ + for (;;) + pause(); +} + static const char *const ioprio_class_table[] = { [IOPRIO_CLASS_NONE] = "none", [IOPRIO_CLASS_RT] = "realtime", |