Skip to content

Commit

Permalink
[linux] Maintain original output for pidfd in linux 6.9
Browse files Browse the repository at this point in the history
  • Loading branch information
jiegec committed May 17, 2024
1 parent 3729186 commit 51651c2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
3 changes: 3 additions & 0 deletions 00DIST
Original file line number Diff line number Diff line change
Expand Up @@ -5605,6 +5605,9 @@ Supplement Regenerated the 4.04 distribution to correct a non-

[linux] Do not embed kernel version in CFLAGS (#314)

[linux] Linux 6.9 changed the pidfs appearence in procfs. Try
to maintain original output in lsof (#317)


Vic Abell <abe@purdue.edu>
July 14, 2018
Expand Down
11 changes: 11 additions & 0 deletions lib/dialects/linux/dproc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1338,6 +1338,17 @@ static int process_id(struct lsof_context *ctx, /* context */
Lf->sf |= SELPTYINFO;
}
#endif /* defined(HASEPTOPTS) && defined(HASPTYEPT) */
else if (Lf->ntype == N_REGLR && rest && *rest) {
// https://github.com/lsof-org/lsof/issues/317
// pidfd since Linux 6.9 becomes a regular file:
// /proc/PID/fd/3 -> pidfd:[PID]
// rest points to "[PID]"
if (sscanf(rest, "[%d]", &fi.pid) == 1) {
(void)snpf(rest, sizeof(pbuf) - (rest - pbuf),
"[pidfd:%d]", fi.pid);
enter_nm(ctx, rest);
}
}

if (Lf->sf)
link_lfile(ctx);
Expand Down

0 comments on commit 51651c2

Please sign in to comment.