Yeah. I didn't really work through all the complexity of anarray-based solution, but you make good points toward the
"this patch is simplest" idea. In any event, it can also be
just a step in the right direction.
I started with `strace` as well, but at least on Linux with
sequentially increasing PIDs you can do this to count forks:
a=($(zsh -c 'echo $$; zsh -lic echo\ \$\$; :'))
echo $((a[2] - a[1]))
and many other ways like `grep processes /proc/stat` (with
various assumptions about system activity across the polls).
`strace` is most precise, of course.
I've been using this patch without issue since around October,
but since release talk is gearing up, I thought I should post
it. Only about a 5..10% performance effect for me, but some
systems might fork much more slowly. (Cygwin used to be like
that, for example.)