diff options
author | Lennart Poettering <lennart@poettering.net> | 2023-10-17 10:16:31 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2023-10-18 14:39:33 +0200 |
commit | d7d748548bca77c6658050348af4cb8dbae14828 (patch) | |
tree | 32348bfd3fc0b13af6a9bfcf3a1fdbd6072c4802 | |
parent | dbus-unit: make sure GetProcesses() D-Bus call internally uses pidfd (diff) | |
download | systemd-d7d748548bca77c6658050348af4cb8dbae14828.tar.xz systemd-d7d748548bca77c6658050348af4cb8dbae14828.zip |
process-util: add pidref_get_comm() and rename get_process_comm() to pid_get_comm()
28 files changed, 81 insertions, 60 deletions
diff --git a/src/basic/log.c b/src/basic/log.c index 7181f3a2ad..17b9b2afe0 100644 --- a/src/basic/log.c +++ b/src/basic/log.c @@ -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).", diff --git a/src/basic/process-util.c b/src/basic/process-util.c index d607c7eb73..2374387850 100644 --- a/src/basic/process-util.c +++ b/src/basic/process-util.c @@ -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 diff --git a/src/basic/process-util.h b/src/basic/process-util.h index c6f2687697..f49e487bd1 100644 --- a/src/basic/process-util.h +++ b/src/basic/process-util.h @@ -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); diff --git a/src/core/automount.c b/src/core/automount.c index a34bfae3ac..ffda884353 100644 --- a/src/core/automount.c +++ b/src/core/automount.c @@ -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); diff --git a/src/core/manager.c b/src/core/manager.c index 9307a13a79..e0eb91124e 100644 --- a/src/core/manager.c +++ b/src/core/manager.c @@ -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), diff --git a/src/core/service.c b/src/core/service.c index b4bd343bc9..099b0f1045 100644 --- a/src/core/service.c +++ b/src/core/service.c @@ -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)); diff --git a/src/core/unit.c b/src/core/unit.c index 69e758e6d3..507d350e7e 100644 --- a/src/core/unit.c +++ b/src/core/unit.c @@ -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; diff --git a/src/coredump/coredump.c b/src/coredump/coredump.c index 0c30219535..1962512c67 100644 --- a/src/coredump/coredump.c +++ b/src/coredump/coredump.c @@ -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"); diff --git a/src/journal/journald-console.c b/src/journal/journald-console.c index 8595ba3e45..d914f92999 100644 --- a/src/journal/journald-console.c +++ b/src/journal/journald-console.c @@ -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; } diff --git a/src/journal/journald-context.c b/src/journal/journald-context.c index 203e893d1f..3cf337a089 100644 --- a/src/journal/journald-context.c +++ b/src/journal/journald-context.c @@ -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) diff --git a/src/journal/journald-kmsg.c b/src/journal/journald-kmsg.c index de94dc6041..5ee4c7e057 100644 --- a/src/journal/journald-kmsg.c +++ b/src/journal/journald-kmsg.c @@ -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; } diff --git a/src/journal/journald-syslog.c b/src/journal/journald-syslog.c index 1ecbd226da..c1c0a913eb 100644 --- a/src/journal/journald-syslog.c +++ b/src/journal/journald-syslog.c @@ -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; } diff --git a/src/journal/journald-wall.c b/src/journal/journald-wall.c index c8d92c4d3e..79eaac1068 100644 --- a/src/journal/journald-wall.c +++ b/src/journal/journald-wall.c @@ -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; } diff --git a/src/libsystemd/sd-bus/bus-creds.c b/src/libsystemd/sd-bus/bus-creds.c index d2513f1f73..48990a27f0 100644 --- a/src/libsystemd/sd-bus/bus-creds.c +++ b/src/libsystemd/sd-bus/bus-creds.c @@ -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; diff --git a/src/libsystemd/sd-bus/bus-socket.c b/src/libsystemd/sd-bus/bus-socket.c index cfa5633f23..5079d68550 100644 --- a/src/libsystemd/sd-bus/bus-socket.c +++ b/src/libsystemd/sd-bus/bus-socket.c @@ -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); diff --git a/src/libsystemd/sd-bus/test-bus-peersockaddr.c b/src/libsystemd/sd-bus/test-bus-peersockaddr.c index 8bab429624..4774ef6a4c 100644 --- a/src/libsystemd/sd-bus/test-bus-peersockaddr.c +++ b/src/libsystemd/sd-bus/test-bus-peersockaddr.c @@ -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; diff --git a/src/login/inhibit.c b/src/login/inhibit.c index 75dba8c08f..61fbd5df14 100644 --- a/src/login/inhibit.c +++ b/src/login/inhibit.c @@ -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, diff --git a/src/login/loginctl.c b/src/login/loginctl.c index 5248135d00..fdf899c37f 100644 --- a/src/login/loginctl.c +++ b/src/login/loginctl.c @@ -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) diff --git a/src/login/logind-action.c b/src/login/logind-action.c index 54ff795c0d..a2b211933a 100644 --- a/src/login/logind-action.c +++ b/src/login/logind-action.c @@ -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 */ diff --git a/src/login/logind-dbus.c b/src/login/logind-dbus.c index ca1c485a24..b458359c97 100644 --- a/src/login/logind-dbus.c +++ b/src/login/logind-dbus.c @@ -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.", diff --git a/src/machine/machinectl.c b/src/machine/machinectl.c index 9b6a6cebda..c9800282a5 100644 --- a/src/machine/machinectl.c +++ b/src/machine/machinectl.c @@ -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); diff --git a/src/shared/common-signal.c b/src/shared/common-signal.c index e4edd180d8..8e70e365dd 100644 --- a/src/shared/common-signal.c +++ b/src/shared/common-signal.c @@ -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.", diff --git a/src/shared/killall.c b/src/shared/killall.c index 4da6335e10..ac1b69e6bb 100644 --- a/src/shared/killall.c +++ b/src/shared/killall.c @@ -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)); } diff --git a/src/shutdown/umount.c b/src/shutdown/umount.c index 1586c2e214..70585523ae 100644 --- a/src/shutdown/umount.c +++ b/src/shutdown/umount.c @@ -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); diff --git a/src/systemctl/systemctl-logind.c b/src/systemctl/systemctl-logind.c index a4486dcce9..2a697b84e5 100644 --- a/src/systemctl/systemctl-logind.c +++ b/src/systemctl/systemctl-logind.c @@ -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\".", diff --git a/src/systemctl/systemctl-show.c b/src/systemctl/systemctl-show.c index c5ed72d066..0cb75d5dfc 100644 --- a/src/systemctl/systemctl-show.c +++ b/src/systemctl/systemctl-show.c @@ -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); } diff --git a/src/test/test-argv-util.c b/src/test/test-argv-util.c index fcf0c5ebac..5bf2903658 100644 --- a/src/test/test-argv-util.c +++ b/src/test/test-argv-util.c @@ -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 diff --git a/src/test/test-process-util.c b/src/test/test-process-util.c index 460cd318db..ab508867ff 100644 --- a/src/test/test-process-util.c +++ b/src/test/test-process-util.c @@ -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); } |