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.