mirror of
https://github.com/systemd/systemd.git
synced 2026-08-09 17:38:42 +00:00
nsresource: port from PR_GET_NAME to pid_get_comm()
SImilar reasons as for the memfd change: let's normalize behaviour and always use pid_get_comm(). This adds escaping here for the first time, which is a good thing.
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
|
||||
#include <sched.h>
|
||||
#include <sys/prctl.h>
|
||||
|
||||
#include "sd-varlink.h"
|
||||
|
||||
@@ -25,13 +24,15 @@
|
||||
assert_cc(TASK_COMM_LEN == NAMESPACE_NAME_MAX);
|
||||
|
||||
static int make_pid_name(char **ret) {
|
||||
char comm[TASK_COMM_LEN];
|
||||
static uint64_t counter = 0;
|
||||
int r;
|
||||
|
||||
assert(ret);
|
||||
|
||||
if (prctl(PR_GET_NAME, comm) < 0)
|
||||
return -errno;
|
||||
_cleanup_free_ char *comm = NULL;
|
||||
r = pid_get_comm(0, &comm);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
char spid[DECIMAL_STR_MAX(pid_t)];
|
||||
xsprintf(spid, PID_FMT, getpid_cached());
|
||||
|
||||
Reference in New Issue
Block a user