diff --git a/00DIST b/00DIST index d5a03498..9a296113 100644 --- a/00DIST +++ b/00DIST @@ -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 July 14, 2018 diff --git a/lib/dialects/linux/dproc.c b/lib/dialects/linux/dproc.c index cb6bb64f..2af29c1f 100644 --- a/lib/dialects/linux/dproc.c +++ b/lib/dialects/linux/dproc.c @@ -1338,6 +1338,18 @@ 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 && Lf->nm && + strcmp(Lf->nm, "pidfd") == 0) { + // 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);