Since this code runs in darwintrace.dylib, which is preloaded into
various processes at runtime, we cannot assume that SA_RESTART is set,
and we also can't modify the processes' state to enable that. As
a consequence, we must expect system calls to fail with EINTR and
restart them. Notably, this happened for me during installation of
texlive-common with the waitpid() system call for the re-signing
operation.
Address this by doing the waitpid in a loop and restarting it on EINTR.
A Portfile interpreter created by mportopen will only end up actually
executing a subset of all targets, and may not execute any. Therefore,
splitting the code for running targets from that which is needed just
to parse the Portfile improves the speed of mportopen and reduces the
memory used by each open mport (which can really add up when installing
ports with large dependency graphs).
Initially only the portfetch code has been split, creating the new
portfetch_run package.
When attempting to update the local PortIndex from the precomputed
version for the current OS/arch, there is sometimes a preexisting
version with the correct mtime and size, but not the correct content.
With the default options, rsync fails to update it. This change
suppresses skipping based on size and time (for the index-related
files, not the tarball).
This bug has no obvious user-visible effect, since the bad PortIndex
fails the signature check and is then regenerated, costing extra
time but not malfunctioning. It's visible in the debug output.
TESTED:
Now correctly uses the downloaded index in a formerly failing case.
This currently triggers during the gtk3 build, suggesting there's a way
to close the file descriptors that isn't being caught by trace mode.
Work around this by re-establishing the connection when this happens.