process-util: add pidref_get_comm() and rename get_process_comm() to pid_get_comm()
This commit is contained in:
+1
-1
@@ -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).",
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user