]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
basic: move freeze() from shared/exec-util.h to basic/process-util.h
authorLennart Poettering <lennart@poettering.net>
Wed, 20 Oct 2021 11:14:11 +0000 (13:14 +0200)
committerLennart Poettering <lennart@poettering.net>
Fri, 22 Oct 2021 14:34:30 +0000 (16:34 +0200)
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.

src/basic/process-util.c
src/basic/process-util.h
src/shared/exec-util.c
src/shared/exec-util.h

index 5e7ed06ea554073f441a81d8524e1d488ad956d3..fce96dd5ebddfa470a785d0e3bcc0f63d92c7174 100644 (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",
index 7e87f5a17c7eadf3b65f463699ac13824011418e..451d0a5ff4092f4bb364a6fbc4741d46748c9c07 100644 (file)
@@ -202,3 +202,5 @@ int pidfd_get_pid(int fd, pid_t *ret);
 int setpriority_closest(int priority);
 
 bool invoked_as(char *argv[], const char *token);
+
+_noreturn_ void freeze(void);
index 042db7db3f52dc91c8e5bcabdacdcce6ea2c4041..fd0d95c5301caa665c2121041a4e042dee6d50a2 100644 (file)
@@ -448,29 +448,6 @@ ExecCommandFlags exec_command_flags_from_string(const char *s) {
                 return 1 << idx;
 }
 
-_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 (;;) {
-                int r;
-                siginfo_t si = {};
-
-                r = waitid(P_ALL, 0, &si, WEXITED);
-                if (r < 0 && errno != EINTR)
-                        break;
-        }
-
-        /* waitid() failed with an unexpected error, things are really borked. Freeze now! */
-        for (;;)
-                pause();
-}
-
 int fexecve_or_execve(int executable_fd, const char *executable, char *const argv[], char *const envp[]) {
 #if ENABLE_FEXECVE
         execveat(executable_fd, "", argv, envp, AT_EMPTY_PATH);
index 05f8e1af8358bf17094c19e6a8019e9f8362e5c9..21d28608f9991128f68659f45ed5c89fed16312c 100644 (file)
@@ -47,8 +47,6 @@ extern const gather_stdout_callback_t gather_environment[_STDOUT_CONSUME_MAX];
 const char* exec_command_flags_to_string(ExecCommandFlags i);
 ExecCommandFlags exec_command_flags_from_string(const char *s);
 
-_noreturn_ void freeze(void);
-
 int fexecve_or_execve(int executable_fd, const char *executable, char *const argv[], char *const envp[]);
 
 int fork_agent(const char *name, int except[], size_t n_except, pid_t *ret_pid, const char *path, ...) _sentinel_;