]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
process-util: actually move rename_process() over
authorLennart Poettering <lennart@poettering.net>
Tue, 27 Oct 2015 12:56:40 +0000 (13:56 +0100)
committerLennart Poettering <lennart@poettering.net>
Tue, 27 Oct 2015 12:56:40 +0000 (13:56 +0100)
The prototype was moved long ago, actually move the definition over now,
too.

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

index c534656c970ed57d8866631fae782698e8ef8b28..31951cdd4fe309893c01386e0bbea65d4dc0fad4 100644 (file)
@@ -24,6 +24,7 @@
 #include <stdbool.h>
 #include <stdio.h>
 #include <string.h>
+#include <sys/prctl.h>
 #include <sys/types.h>
 #include <sys/wait.h>
 #include <unistd.h>
@@ -180,6 +181,37 @@ int get_process_cmdline(pid_t pid, size_t max_length, bool comm_fallback, char *
         return 0;
 }
 
+void rename_process(const char name[8]) {
+        assert(name);
+
+        /* This is a like a poor man's setproctitle(). It changes the
+         * comm field, argv[0], and also the glibc's internally used
+         * name of the process. For the first one a limit of 16 chars
+         * applies, to the second one usually one of 10 (i.e. length
+         * of "/sbin/init"), to the third one one of 7 (i.e. length of
+         * "systemd"). If you pass a longer string it will be
+         * truncated */
+
+        prctl(PR_SET_NAME, name);
+
+        if (program_invocation_name)
+                strncpy(program_invocation_name, name, strlen(program_invocation_name));
+
+        if (saved_argc > 0) {
+                int i;
+
+                if (saved_argv[0])
+                        strncpy(saved_argv[0], name, strlen(saved_argv[0]));
+
+                for (i = 1; i < saved_argc; i++) {
+                        if (!saved_argv[i])
+                                break;
+
+                        memzero(saved_argv[i], strlen(saved_argv[i]));
+                }
+        }
+}
+
 int is_kernel_thread(pid_t pid) {
         const char *p;
         size_t count;
index db32a34ef3523ab83a441c33b7e2b69223127230..31f760981e5ccc4f6d8da5f0ff38b1d3e3c37497 100644 (file)
@@ -60,8 +60,10 @@ void sigkill_wait(pid_t *pid);
 
 int kill_and_sigcont(pid_t pid, int sig);
 pid_t get_parent_of_pid(pid_t pid, pid_t *ppid);
+
 void rename_process(const char name[8]);
 int is_kernel_thread(pid_t pid);
+
 int getenv_for_pid(pid_t pid, const char *field, char **_value);
 
 bool pid_is_alive(pid_t pid);
index da7de27a046941a078b83450769ec68350801f58..2451da3658cafc08d48f95dac27ab6f107f67f27 100644 (file)
@@ -125,37 +125,6 @@ size_t page_size(void) {
         return pgsz;
 }
 
-void rename_process(const char name[8]) {
-        assert(name);
-
-        /* This is a like a poor man's setproctitle(). It changes the
-         * comm field, argv[0], and also the glibc's internally used
-         * name of the process. For the first one a limit of 16 chars
-         * applies, to the second one usually one of 10 (i.e. length
-         * of "/sbin/init"), to the third one one of 7 (i.e. length of
-         * "systemd"). If you pass a longer string it will be
-         * truncated */
-
-        prctl(PR_SET_NAME, name);
-
-        if (program_invocation_name)
-                strncpy(program_invocation_name, name, strlen(program_invocation_name));
-
-        if (saved_argc > 0) {
-                int i;
-
-                if (saved_argv[0])
-                        strncpy(saved_argv[0], name, strlen(saved_argv[0]));
-
-                for (i = 1; i < saved_argc; i++) {
-                        if (!saved_argv[i])
-                                break;
-
-                        memzero(saved_argv[i], strlen(saved_argv[i]));
-                }
-        }
-}
-
 noreturn void freeze(void) {
 
         /* Make sure nobody waits for us on a socket anymore */