Re: [PATCH 1/4] trace2: add macOS process ancestry tracing
On 2/9/2026 10:13 AM, Matthew John Cheetham wrote:
> On 09/02/2026 14:36, Derrick Stolee wrote:
Show 17 quoted lines
>>> + /*
>>> + * Recurse to the parent process. Stop if ppid is 0 or 1
>>> + * (init/launchd) or if we've reached ourselves (cycle).
>>> + */
>>> + if (ppid > 1 && ppid != pid)
>>> + push_ancestry_name(names, ppid, depth + 1);
>>
>> This kind of tail recursion could be easily converted into a loop. I
>> usually prefer loops to recursion when possible, in case we want to allow
>> an unlimited number of parents in the future.
>
> I had based this on the compat/linux/procinfo.c implementation which
> also uses recursion to walk the parent processes (and also defines an
> upper limit to the number of processes to walk).
>
> If I were to transform this to a loop, would we not also be wanting to
> update linux/procinfo.c too?
If you're matching the structure in the Linux version, then keep it.
If it's worth fixing, then it would be worth fixing in both places at
a later time.
Thanks,
-Stolee