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.
This commit is contained in:
Lennart Poettering
2021-10-20 13:14:11 +02:00
parent 197aec7e79
commit 8ddefb8eef
4 changed files with 23 additions and 25 deletions

View File

@@ -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",