]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
process-util: add pidref_get_comm() and rename get_process_comm() to pid_get_comm()
authorLennart Poettering <lennart@poettering.net>
Tue, 17 Oct 2023 08:16:31 +0000 (10:16 +0200)
committerLennart Poettering <lennart@poettering.net>
Wed, 18 Oct 2023 12:39:33 +0000 (14:39 +0200)
28 files changed:
src/basic/log.c
src/basic/process-util.c
src/basic/process-util.h
src/core/automount.c
src/core/manager.c
src/core/service.c
src/core/unit.c
src/coredump/coredump.c
src/journal/journald-console.c
src/journal/journald-context.c
src/journal/journald-kmsg.c
src/journal/journald-syslog.c
src/journal/journald-wall.c
src/libsystemd/sd-bus/bus-creds.c
src/libsystemd/sd-bus/bus-socket.c
src/libsystemd/sd-bus/test-bus-peersockaddr.c
src/login/inhibit.c
src/login/loginctl.c
src/login/logind-action.c
src/login/logind-dbus.c
src/machine/machinectl.c
src/shared/common-signal.c
src/shared/killall.c
src/shutdown/umount.c
src/systemctl/systemctl-logind.c
src/systemctl/systemctl-show.c
src/test/test-argv-util.c
src/test/test-process-util.c

index 7181f3a2ad18a11d14646920df272271767677ec..17b9b2afe09549ae2712dade579d8394a4470e52 100644 (file)
@@ -1451,7 +1451,7 @@ void log_received_signal(int level, const struct signalfd_siginfo *si) {
         if (pid_is_valid(si->ssi_pid)) {
                 _cleanup_free_ char *p = NULL;
 
-                (void) get_process_comm(si->ssi_pid, &p);
+                (void) pid_get_comm(si->ssi_pid, &p);
 
                 log_full(level,
                          "Received SIG%s from PID %"PRIu32" (%s).",
index d607c7eb7310eadfd4fb43eb15865ba189b6f07c..2374387850831723c60f583d72f13b674fa997c8 100644 (file)
@@ -94,7 +94,7 @@ static int get_process_state(pid_t pid) {
         return (unsigned char) state;
 }
 
-int get_process_comm(pid_t pid, char **ret) {
+int pid_get_comm(pid_t pid, char **ret) {
         _cleanup_free_ char *escaped = NULL, *comm = NULL;
         int r;
 
@@ -132,6 +132,26 @@ int get_process_comm(pid_t pid, char **ret) {
         return 0;
 }
 
+int pidref_get_comm(const PidRef *pid, char **ret) {
+        _cleanup_free_ char *comm = NULL;
+        int r;
+
+        if (!pidref_is_set(pid))
+                return -ESRCH;
+
+        r = pid_get_comm(pid->pid, &comm);
+        if (r < 0)
+                return r;
+
+        r = pidref_verify(pid);
+        if (r < 0)
+                return r;
+
+        if (ret)
+                *ret = TAKE_PTR(comm);
+        return 0;
+}
+
 static int pid_get_cmdline_nulstr(
                 pid_t pid,
                 size_t max_size,
@@ -170,7 +190,7 @@ static int pid_get_cmdline_nulstr(
                 /* Kernel threads have no argv[] */
                 _cleanup_free_ char *comm = NULL;
 
-                r = get_process_comm(pid, &comm);
+                r = pid_get_comm(pid, &comm);
                 if (r < 0)
                         return r;
 
@@ -752,7 +772,7 @@ int wait_for_terminate_and_check(const char *name, pid_t pid, WaitFlags flags) {
         assert(pid > 1);
 
         if (!name) {
-                r = get_process_comm(pid, &buffer);
+                r = pid_get_comm(pid, &buffer);
                 if (r < 0)
                         log_debug_errno(r, "Failed to acquire process name of " PID_FMT ", ignoring: %m", pid);
                 else
index c6f2687697258b12747f93c2c41693a8d9f3df09..f49e487bd1be4df99496095b19b5d72eac720f18 100644 (file)
@@ -39,7 +39,8 @@ typedef enum ProcessCmdlineFlags {
         PROCESS_CMDLINE_QUOTE_POSIX   = 1 << 3,
 } ProcessCmdlineFlags;
 
-int get_process_comm(pid_t pid, char **ret);
+int pid_get_comm(pid_t pid, char **ret);
+int pidref_get_comm(const PidRef *pid, char **ret);
 int pid_get_cmdline(pid_t pid, size_t max_columns, ProcessCmdlineFlags flags, char **ret);
 int pidref_get_cmdline(const PidRef *pid, size_t max_columns, ProcessCmdlineFlags flags, char **ret);
 int pid_get_cmdline_strv(pid_t pid, ProcessCmdlineFlags flags, char ***ret);
index a34bfae3ac819e1a5804d46c411730aa4b290de7..ffda884353823fe880c5bb6e2a58cc1e1ad60b6c 100644 (file)
@@ -997,7 +997,7 @@ static int automount_dispatch_io(sd_event_source *s, int fd, uint32_t events, vo
                 if (packet.v5_packet.pid > 0) {
                         _cleanup_free_ char *p = NULL;
 
-                        (void) get_process_comm(packet.v5_packet.pid, &p);
+                        (void) pid_get_comm(packet.v5_packet.pid, &p);
                         log_unit_info(UNIT(a), "Got automount request for %s, triggered by %"PRIu32" (%s)", a->where, packet.v5_packet.pid, strna(p));
                 } else
                         log_unit_debug(UNIT(a), "Got direct mount request on %s", a->where);
index 9307a13a79ffd71785ea3e22b7c77be86f14833a..e0eb91124e8cada75500f110bcb85f16911fd5c4 100644 (file)
@@ -2823,7 +2823,7 @@ static int manager_dispatch_sigchld(sd_event_source *source, void *userdata) {
                 _cleanup_free_ char *name = NULL;
                 Unit *u1, *u2, **array;
 
-                (void) get_process_comm(si.si_pid, &name);
+                (void) pid_get_comm(si.si_pid, &name);
 
                 log_debug("Child "PID_FMT" (%s) died (code=%s, status=%i/%s)",
                           si.si_pid, strna(name),
index b4bd343bc9486160b12ea0b98b9234d59e2966e9..099b0f10452bbf7ad2c0d1602b8ba5a60f9aa367 100644 (file)
@@ -2295,7 +2295,7 @@ static void service_kill_control_process(Service *s) {
         if (r < 0) {
                 _cleanup_free_ char *comm = NULL;
 
-                (void) get_process_comm(s->control_pid.pid, &comm);
+                (void) pidref_get_comm(&s->control_pid, &comm);
 
                 log_unit_debug_errno(UNIT(s), r, "Failed to kill control process " PID_FMT " (%s), ignoring: %m",
                                      s->control_pid.pid, strna(comm));
index 69e758e6d35f9ba89a23440b1431323648e406f5..507d350e7ede761d8483b34949f584e5e7b830cf 100644 (file)
@@ -4010,7 +4010,7 @@ static int kill_common_log(pid_t pid, int signo, void *userdata) {
         _cleanup_free_ char *comm = NULL;
         Unit *u = ASSERT_PTR(userdata);
 
-        (void) get_process_comm(pid, &comm);
+        (void) pid_get_comm(pid, &comm);
         log_unit_info(u, "Sending signal SIG%s to process " PID_FMT " (%s) on client request.",
                       signal_to_string(signo), pid, strna(comm));
 
@@ -4081,7 +4081,7 @@ int unit_kill(
         if (pidref_is_set(control_pid) &&
             IN_SET(who, KILL_CONTROL, KILL_CONTROL_FAIL, KILL_ALL, KILL_ALL_FAIL)) {
                 _cleanup_free_ char *comm = NULL;
-                (void) get_process_comm(control_pid->pid, &comm);
+                (void) pidref_get_comm(control_pid, &comm);
 
                 r = kill_or_sigqueue(control_pid, signo, code, value);
                 if (r < 0) {
@@ -4107,7 +4107,7 @@ int unit_kill(
             IN_SET(who, KILL_MAIN, KILL_MAIN_FAIL, KILL_ALL, KILL_ALL_FAIL)) {
 
                 _cleanup_free_ char *comm = NULL;
-                (void) get_process_comm(main_pid->pid, &comm);
+                (void) pidref_get_comm(main_pid, &comm);
 
                 r = kill_or_sigqueue(main_pid, signo, code, value);
                 if (r < 0) {
@@ -4732,7 +4732,7 @@ int unit_make_transient(Unit *u) {
 static int log_kill(pid_t pid, int sig, void *userdata) {
         _cleanup_free_ char *comm = NULL;
 
-        (void) get_process_comm(pid, &comm);
+        (void) pid_get_comm(pid, &comm);
 
         /* Don't log about processes marked with brackets, under the assumption that these are temporary processes
            only, like for example systemd's own PAM stub process. */
@@ -4820,7 +4820,7 @@ int unit_kill_context(
                 r = pidref_kill_and_sigcont(main_pid, sig);
                 if (r < 0 && r != -ESRCH) {
                         _cleanup_free_ char *comm = NULL;
-                        (void) get_process_comm(main_pid->pid, &comm);
+                        (void) pidref_get_comm(main_pid, &comm);
 
                         log_unit_warning_errno(u, r, "Failed to kill main process " PID_FMT " (%s), ignoring: %m", main_pid->pid, strna(comm));
                 } else {
@@ -4839,7 +4839,7 @@ int unit_kill_context(
                 r = pidref_kill_and_sigcont(control_pid, sig);
                 if (r < 0 && r != -ESRCH) {
                         _cleanup_free_ char *comm = NULL;
-                        (void) get_process_comm(control_pid->pid, &comm);
+                        (void) pidref_get_comm(control_pid, &comm);
 
                         log_unit_warning_errno(u, r, "Failed to kill control process " PID_FMT " (%s), ignoring: %m", control_pid->pid, strna(comm));
                 } else {
@@ -5865,7 +5865,7 @@ static bool ignore_leftover_process(const char *comm) {
 int unit_log_leftover_process_start(pid_t pid, int sig, void *userdata) {
         _cleanup_free_ char *comm = NULL;
 
-        (void) get_process_comm(pid, &comm);
+        (void) pid_get_comm(pid, &comm);
 
         if (ignore_leftover_process(comm))
                 return 0;
@@ -5883,7 +5883,7 @@ int unit_log_leftover_process_start(pid_t pid, int sig, void *userdata) {
 int unit_log_leftover_process_stop(pid_t pid, int sig, void *userdata) {
         _cleanup_free_ char *comm = NULL;
 
-        (void) get_process_comm(pid, &comm);
+        (void) pid_get_comm(pid, &comm);
 
         if (ignore_leftover_process(comm))
                 return 0;
index 0c302195351acbf200656e83ea4067e52c0daabb..1962512c67b4afdb2045eec03f40820a34807624 100644 (file)
@@ -1218,7 +1218,7 @@ static int gather_pid_metadata_from_procfs(struct iovec_wrapper *iovw, Context *
         pid = context->pid;
 
         /* The following is mandatory */
-        r = get_process_comm(pid, &t);
+        r = pid_get_comm(pid, &t);
         if (r < 0)
                 return log_error_errno(r, "Failed to get COMM: %m");
 
index 8595ba3e453ba420a2c46afd4d9f8aaf0e2dd362..d914f92999d6eae40e1c941a1b289b977c818f32 100644 (file)
@@ -66,7 +66,7 @@ void server_forward_console(
         /* Second: identifier and PID */
         if (ucred) {
                 if (!identifier) {
-                        (void) get_process_comm(ucred->pid, &ident_buf);
+                        (void) pid_get_comm(ucred->pid, &ident_buf);
                         identifier = ident_buf;
                 }
 
index 203e893d1f1972d3ec1e99881f78c94b98a59be8..3cf337a0897902f1f16727a88e37fceabf2e9d1a 100644 (file)
@@ -224,7 +224,7 @@ static void client_context_read_basic(ClientContext *c) {
         assert(c);
         assert(pid_is_valid(c->pid));
 
-        if (get_process_comm(c->pid, &t) >= 0)
+        if (pid_get_comm(c->pid, &t) >= 0)
                 free_and_replace(c->comm, t);
 
         if (get_process_exe(c->pid, &t) >= 0)
index de94dc6041cb1f466d587ad26c0f4aa941758534..5ee4c7e05736317251c27450bf5903665d4251c0 100644 (file)
@@ -61,7 +61,7 @@ void server_forward_kmsg(
         /* Second: identifier and PID */
         if (ucred) {
                 if (!identifier) {
-                        (void) get_process_comm(ucred->pid, &ident_buf);
+                        (void) pid_get_comm(ucred->pid, &ident_buf);
                         identifier = ident_buf;
                 }
 
index 1ecbd226da923d0bfa7fbf34125a944e25025489..c1c0a913eb86841baad51bcf1b6ec8cf61d392f9 100644 (file)
@@ -154,7 +154,7 @@ void server_forward_syslog(Server *s, int priority, const char *identifier, cons
         /* Third: identifier and PID */
         if (ucred) {
                 if (!identifier) {
-                        (void) get_process_comm(ucred->pid, &ident_buf);
+                        (void) pid_get_comm(ucred->pid, &ident_buf);
                         identifier = ident_buf;
                 }
 
index c8d92c4d3e3661ced812abe2c38d28e3f961d932..79eaac1068aebe9455382f0b7dc53bb2517e3461 100644 (file)
@@ -27,7 +27,7 @@ void server_forward_wall(
 
         if (ucred) {
                 if (!identifier) {
-                        (void) get_process_comm(ucred->pid, &ident_buf);
+                        (void) pid_get_comm(ucred->pid, &ident_buf);
                         identifier = ident_buf;
                 }
 
index d2513f1f738753d10cde133198c607017953ac6f..48990a27f097ece6624ab6db55b40dba49894372 100644 (file)
@@ -969,7 +969,7 @@ int bus_creds_add_more(sd_bus_creds *c, uint64_t mask, pid_t pid, pid_t tid) {
         }
 
         if (missing & SD_BUS_CREDS_COMM) {
-                r = get_process_comm(pid, &c->comm);
+                r = pid_get_comm(pid, &c->comm);
                 if (r < 0) {
                         if (!ERRNO_IS_PRIVILEGE(r))
                                 return r;
index cfa5633f23577b1e5271078d77f7a1c60312c726..5079d6855002aa56761ef43942d2cc4edfbcf224 100644 (file)
@@ -920,7 +920,7 @@ static int bind_description(sd_bus *b, int fd, int family) {
          * - a random 64-bit value (to avoid collisions)
          * - our "comm" process name (suppressed if contains "/" to avoid parsing issues)
          * - the description string of the bus connection. */
-        (void) get_process_comm(0, &comm);
+        (void) pid_get_comm(0, &comm);
         if (comm && strchr(comm, '/'))
                 comm = mfree(comm);
 
index 8bab429624279f50ab4498320387c6bd30951189..4774ef6a4c60ebef3d43375dfffa7c69407dcefe 100644 (file)
@@ -47,7 +47,7 @@ static void *server(void *p) {
 
         const char *comm;
         assert_se(sd_bus_creds_get_comm(c, &comm) >= 0);
-        assert_se(get_process_comm(0, &our_comm) >= 0);
+        assert_se(pid_get_comm(0, &our_comm) >= 0);
         assert_se(streq_ptr(comm, our_comm));
 
         const char *description;
index 75dba8c08f5dde213ff65efda91ec84d26f7f2a1..61fbd5df148bb373368748de256f2ab6208c9af7 100644 (file)
@@ -91,7 +91,7 @@ static int print_inhibitors(sd_bus *bus) {
                 if (arg_mode && !streq(mode, arg_mode))
                         continue;
 
-                (void) get_process_comm(pid, &comm);
+                (void) pid_get_comm(pid, &comm);
                 u = uid_to_name(uid);
 
                 r = table_add_many(table,
index 5248135d006e033e811d8406956fdf16ead9be5e..fdf899c37f1570dd71f11971b556f98d44f2251e 100644 (file)
@@ -525,7 +525,7 @@ static int print_session_status_info(sd_bus *bus, const char *path) {
         if (i.leader > 0) {
                 _cleanup_free_ char *name = NULL;
 
-                (void) get_process_comm(i.leader, &name);
+                (void) pid_get_comm(i.leader, &name);
 
                 r = table_add_cell(table, NULL, TABLE_FIELD, "Leader");
                 if (r < 0)
index 54ff795c0d8f4915024b76e23c91f2ca7e2a80f1..a2b211933a2459f44a322d8f9e2bbd2bb41e2669 100644 (file)
@@ -239,7 +239,7 @@ int manager_handle_action(
             manager_is_inhibited(m, inhibit_operation, INHIBIT_BLOCK, NULL, false, false, 0, &offending)) {
                 _cleanup_free_ char *comm = NULL, *u = NULL;
 
-                (void) get_process_comm(offending->pid.pid, &comm);
+                (void) pidref_get_comm(&offending->pid, &comm);
                 u = uid_to_name(offending->uid);
 
                 /* If this is just a recheck of the lid switch then don't warn about anything */
index ca1c485a24696ed07e59c28e24ffd30ef961eb60..b458359c971b8605ba51b3533698cd71a181076b 100644 (file)
@@ -1650,7 +1650,7 @@ int manager_dispatch_delayed(Manager *manager, bool timeout) {
                 if (!timeout)
                         return 0;
 
-                (void) get_process_comm(offending->pid.pid, &comm);
+                (void) pidref_get_comm(&offending->pid, &comm);
                 u = uid_to_name(offending->uid);
 
                 log_notice("Delay lock is active (UID "UID_FMT"/%s, PID "PID_FMT"/%s) but inhibitor timeout is reached.",
index 9b6a6cebda74fbe1b9d84e211b6aab4da716babf..c9800282a56ced2480c4ec7262bb060d61f49284 100644 (file)
@@ -526,7 +526,7 @@ static void print_machine_status_info(sd_bus *bus, MachineStatusInfo *i) {
 
                 printf("\t  Leader: %u", (unsigned) i->leader);
 
-                (void) get_process_comm(i->leader, &t);
+                (void) pid_get_comm(i->leader, &t);
                 if (t)
                         printf(" (%s)", t);
 
index e4edd180d8e3d253da21bd269f102c8d77425b23..8e70e365dd69a4fd14b0b7ad531836a40321828b 100644 (file)
@@ -14,7 +14,7 @@ int sigrtmin18_handler(sd_event_source *s, const struct signalfd_siginfo *si, vo
         assert(s);
         assert(si);
 
-        (void) get_process_comm(si->ssi_pid, &comm);
+        (void) pid_get_comm(si->ssi_pid, &comm);
 
         if (si->ssi_code != SI_QUEUE) {
                 log_notice("Received control signal %s from process " PID_FMT " (%s) without command value, ignoring.",
index 4da6335e10b37352cf55e37d1c8ad3ddc3a1a411..ac1b69e6bb94fe4f067ea48553b97b0943c8f1bc 100644 (file)
@@ -101,7 +101,7 @@ static bool ignore_proc(pid_t pid, bool warn_rootfs) {
 
                 _cleanup_free_ char *comm = NULL;
 
-                (void) get_process_comm(pid, &comm);
+                (void) pid_get_comm(pid, &comm);
 
                 log_notice("Process " PID_FMT " (%s) has been marked to be excluded from killing. It is "
                            "running from the root file system, and thus likely to block re-mounting of the "
@@ -120,7 +120,7 @@ static void log_children_no_yet_killed(Set *pids) {
         SET_FOREACH(p, pids) {
                 _cleanup_free_ char *s = NULL;
 
-                if (get_process_comm(PTR_TO_PID(p), &s) >= 0)
+                if (pid_get_comm(PTR_TO_PID(p), &s) >= 0)
                         r = strextendf(&lst_child, ", " PID_FMT " (%s)", PTR_TO_PID(p), s);
                 else
                         r = strextendf(&lst_child, ", " PID_FMT, PTR_TO_PID(p));
@@ -248,7 +248,7 @@ static int killall(int sig, Set *pids, bool send_sighup) {
                 if (sig == SIGKILL) {
                         _cleanup_free_ char *s = NULL;
 
-                        (void) get_process_comm(pid, &s);
+                        (void) pid_get_comm(pid, &s);
                         log_notice("Sending SIGKILL to PID "PID_FMT" (%s).", pid, strna(s));
                 }
 
index 1586c2e2141142195f61e2e300773ab188d17bf3..70585523ae73e0c67e9bb22407dd1acfe32bfc90 100644 (file)
@@ -222,7 +222,7 @@ static void log_umount_blockers(const char *mnt) {
                         continue;
 
                 _cleanup_free_ char *comm = NULL;
-                r = get_process_comm(pid, &comm);
+                r = pid_get_comm(pid, &comm);
                 if (r < 0) {
                         if (r != -ESRCH) /* process gone by now */
                                 log_debug_errno(r, "Failed to read process name of PID " PID_FMT ": %m", pid);
index a4486dcce902c3e81390c64aab90f17347436c29..2a697b84e53f976166efd30e6b5d90fb5b77ba6b 100644 (file)
@@ -168,7 +168,7 @@ int logind_check_inhibitors(enum action a) {
                                           ACTION_KEXEC) ? "shutdown" : "sleep"))
                         continue;
 
-                (void) get_process_comm(pid, &comm);
+                (void) pid_get_comm(pid, &comm);
                 user = uid_to_name(uid);
 
                 log_warning("Operation inhibited by \"%s\" (PID "PID_FMT" \"%s\", user %s), reason is \"%s\".",
index c5ed72d0664e95f5f404fecc59715adb04e7e7c7..0cb75d5dfc14da15e2ff0ed1090afe4390419b34 100644 (file)
@@ -626,7 +626,7 @@ static void print_status_info(
                                 if (arg_transport == BUS_TRANSPORT_LOCAL) {
                                         _cleanup_free_ char *comm = NULL;
 
-                                        (void) get_process_comm(i->main_pid, &comm);
+                                        (void) pid_get_comm(i->main_pid, &comm);
                                         if (comm)
                                                 printf(" (%s)", comm);
                                 }
@@ -661,7 +661,7 @@ static void print_status_info(
                         printf(PID_FMT, i->control_pid);
 
                         if (arg_transport == BUS_TRANSPORT_LOCAL) {
-                                (void) get_process_comm(i->control_pid, &c);
+                                (void) pid_get_comm(i->control_pid, &c);
                                 if (c)
                                         printf(" (%s)", c);
                         }
index fcf0c5ebac218ea903d4bf27e9111d75a000da07..5bf2903658b09d4dc1bc59c6816aa49bccd5d799 100644 (file)
@@ -35,7 +35,7 @@ static void test_rename_process_now(const char *p, int ret) {
                 return;
 #endif
 
-        assert_se(get_process_comm(0, &comm) >= 0);
+        assert_se(pid_get_comm(0, &comm) >= 0);
         log_debug("comm = <%s>", comm);
         assert_se(strneq(comm, p, TASK_COMM_LEN-1));
         /* We expect comm to be at most 16 bytes (TASK_COMM_LEN). The kernel may raise this limit in the
index 460cd318db8314a4cae6b7f11d1c91bede0b210f..ab508867ff67f87ba8c35f02f848d894f5e00633 100644 (file)
@@ -38,7 +38,7 @@
 #include "user-util.h"
 #include "virt.h"
 
-static void test_get_process_comm_one(pid_t pid) {
+static void test_pid_get_comm_one(pid_t pid) {
         struct stat st;
         _cleanup_free_ char *a = NULL, *c = NULL, *d = NULL, *f = NULL, *i = NULL;
         _cleanup_free_ char *env = NULL;
@@ -54,7 +54,7 @@ static void test_get_process_comm_one(pid_t pid) {
         xsprintf(path, "/proc/"PID_FMT"/comm", pid);
 
         if (stat(path, &st) == 0) {
-                assert_se(get_process_comm(pid, &a) >= 0);
+                assert_se(pid_get_comm(pid, &a) >= 0);
                 log_info("PID"PID_FMT" comm: '%s'", pid, a);
         } else
                 log_warning("%s not exist.", path);
@@ -99,15 +99,15 @@ static void test_get_process_comm_one(pid_t pid) {
         log_info("PID"PID_FMT" $PATH: '%s'", pid, strna(i));
 }
 
-TEST(get_process_comm) {
+TEST(pid_get_comm) {
         if (saved_argc > 1) {
                 pid_t pid = 0;
 
                 (void) parse_pid(saved_argv[1], &pid);
-                test_get_process_comm_one(pid);
+                test_pid_get_comm_one(pid);
         } else {
-                TEST_REQ_RUNNING_SYSTEMD(test_get_process_comm_one(1));
-                test_get_process_comm_one(getpid());
+                TEST_REQ_RUNNING_SYSTEMD(test_pid_get_comm_one(1));
+                test_pid_get_comm_one(getpid());
         }
 }
 
@@ -165,34 +165,34 @@ TEST(pid_get_cmdline) {
         }
 }
 
-static void test_get_process_comm_escape_one(const char *input, const char *output) {
+static void test_pid_get_comm_escape_one(const char *input, const char *output) {
         _cleanup_free_ char *n = NULL;
 
         log_debug("input: <%s> — output: <%s>", input, output);
 
         assert_se(prctl(PR_SET_NAME, input) >= 0);
-        assert_se(get_process_comm(0, &n) >= 0);
+        assert_se(pid_get_comm(0, &n) >= 0);
 
         log_debug("got: <%s>", n);
 
         assert_se(streq_ptr(n, output));
 }
 
-TEST(get_process_comm_escape) {
+TEST(pid_get_comm_escape) {
         _cleanup_free_ char *saved = NULL;
 
-        assert_se(get_process_comm(0, &saved) >= 0);
-
-        test_get_process_comm_escape_one("", "");
-        test_get_process_comm_escape_one("foo", "foo");
-        test_get_process_comm_escape_one("012345678901234", "012345678901234");
-        test_get_process_comm_escape_one("0123456789012345", "012345678901234");
-        test_get_process_comm_escape_one("äöüß", "\\303\\244\\303\\266\\303\\274\\303\\237");
-        test_get_process_comm_escape_one("xäöüß", "x\\303\\244\\303\\266\\303\\274\\303\\237");
-        test_get_process_comm_escape_one("xxäöüß", "xx\\303\\244\\303\\266\\303\\274\\303\\237");
-        test_get_process_comm_escape_one("xxxäöüß", "xxx\\303\\244\\303\\266\\303\\274\\303\\237");
-        test_get_process_comm_escape_one("xxxxäöüß", "xxxx\\303\\244\\303\\266\\303\\274\\303\\237");
-        test_get_process_comm_escape_one("xxxxxäöüß", "xxxxx\\303\\244\\303\\266\\303\\274\\303\\237");
+        assert_se(pid_get_comm(0, &saved) >= 0);
+
+        test_pid_get_comm_escape_one("", "");
+        test_pid_get_comm_escape_one("foo", "foo");
+        test_pid_get_comm_escape_one("012345678901234", "012345678901234");
+        test_pid_get_comm_escape_one("0123456789012345", "012345678901234");
+        test_pid_get_comm_escape_one("äöüß", "\\303\\244\\303\\266\\303\\274\\303\\237");
+        test_pid_get_comm_escape_one("xäöüß", "x\\303\\244\\303\\266\\303\\274\\303\\237");
+        test_pid_get_comm_escape_one("xxäöüß", "xx\\303\\244\\303\\266\\303\\274\\303\\237");
+        test_pid_get_comm_escape_one("xxxäöüß", "xxx\\303\\244\\303\\266\\303\\274\\303\\237");
+        test_pid_get_comm_escape_one("xxxxäöüß", "xxxx\\303\\244\\303\\266\\303\\274\\303\\237");
+        test_pid_get_comm_escape_one("xxxxxäöüß", "xxxxx\\303\\244\\303\\266\\303\\274\\303\\237");
 
         assert_se(prctl(PR_SET_NAME, saved) >= 0);
 }