summaryrefslogtreecommitdiff
path: root/src/basic/process-util.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2021-10-20 13:14:11 +0200
committerLennart Poettering <lennart@poettering.net>2021-10-22 16:34:30 +0200
commit8ddefb8eef412f888b230588ebde832fc50dc781 (patch)
tree86937d0c715afe03295cc6a10d1cdd447475074f /src/basic/process-util.c
parent197aec7e79d2f61c50b1684317c11d36968a83f2 (diff)
downloadsystemd-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.c21
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",