Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

realtime: Fix parsing status file of host processes #1513

Merged
merged 1 commit into from
Nov 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions src/xdp-utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -748,13 +748,29 @@ parse_status_field_pid (const char *val,
{
const char *t;

/* Takes "Pid: 12345" */
t = strrchr (val, '\t');
if (t == NULL)
return -ENOENT;
g_assert (t);

return parse_pid (t, pid);
}


static int
parse_status_field_nspid (const char *val,
pid_t *pid)
{
const char *t;

/* This is a tab separated list of namespaces.
* We only want the innermost namespace. */
t = strrchr (val, '\t');
if (t != NULL)
val = t;

return parse_pid (val, pid);
TingPing marked this conversation as resolved.
Show resolved Hide resolved
}

static pid_t
pidfd_to_pid (int fdinfo,
const int pidfd,
Expand Down Expand Up @@ -998,7 +1014,7 @@ parse_status_file (int pid_fd,

if (!strncmp (key, "NSpid", strlen ("NSpid")))
{
r = parse_status_field_pid (val, pid_out);
r = parse_status_field_nspid (val, pid_out);
have_pid = r > -1;
}
else if (!strncmp (key, "Uid", strlen ("Uid")))
Expand Down
Loading