From ec6159d497c6d58fa7112b7fe38233fc2f87deed Mon Sep 17 00:00:00 2001 From: hja Date: Mon, 16 Nov 2026 21:57:46 +0000 Subject: [PATCH] darwin: retry full file descriptor lists --- lib/dialects/darwin/dproc.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/dialects/darwin/dproc.c b/lib/dialects/darwin/dproc.c index 8b3ea2c3..3263a8f0 100644 --- a/lib/dialects/darwin/dproc.c +++ b/lib/dialects/darwin/dproc.c @@ -415,6 +415,7 @@ static void process_fds(struct lsof_context *ctx, /* context */ { int i, isock, nb, nf; struct proc_fdinfo *fdp; +retry: /* * Make sure an FD buffer has been allocated. */ @@ -457,6 +458,11 @@ static void process_fds(struct lsof_context *ctx, /* context */ link_lfile(ctx); return; } + /* A full buffer may omit descriptors opened since the task-info query. */ + if (nb + sizeof(struct proc_fdinfo) > NbFds) { + n = NbFds / sizeof(struct proc_fdinfo) + 32; + goto retry; + } nf = (int)(nb / sizeof(struct proc_fdinfo)); /* * Loop through the file descriptors.