diff options
author | jade <lix@jade.fyi> | 2024-08-09 19:24:29 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@localhost> | 2024-08-09 19:24:29 +0000 |
commit | 790d1079e1da414f730c9d03c4c8ecc4c40d5c4d (patch) | |
tree | 96d592510b99f59ceb1b7b4bc8537d2981a7b23b /src | |
parent | 346e340cbfe450df3709cf5d51e26ba247a2c1ad (diff) | |
parent | d1fd1dc8acbbbb3003fc633a9ffe7c8fb4b63e28 (diff) |
Merge changes Ib7c80826,I636f8a71,I67669b98 into main
* changes:
perl: un-autos your conf
build: declare all the deps as -isystem
darwin: workaround PROC_PIDLISTFDS on processes with no fds
Diffstat (limited to 'src')
-rw-r--r-- | src/libstore/platform/darwin.cc | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/libstore/platform/darwin.cc b/src/libstore/platform/darwin.cc index 1b591fde3..1f7e9be23 100644 --- a/src/libstore/platform/darwin.cc +++ b/src/libstore/platform/darwin.cc @@ -56,12 +56,27 @@ void DarwinLocalStore::findPlatformRoots(UncheckedRoots & unchecked) while (fdBufSize > fds.size() * sizeof(struct proc_fdinfo)) { // Reserve some extra size so we don't fail too much fds.resize((fdBufSize + fdBufSize / 8) / sizeof(struct proc_fdinfo)); + errno = 0; fdBufSize = proc_pidinfo( pid, PROC_PIDLISTFDS, 0, fds.data(), fds.size() * sizeof(struct proc_fdinfo) ); + // errno == 0???! Yes, seriously. This is because macOS has a + // broken syscall wrapper for proc_pidinfo that has no way of + // dealing with the system call successfully returning 0. It + // takes the -1 error result from the errno-setting syscall + // wrapper and turns it into a 0 result. But what if the system + // call actually returns 0? Then you get an errno of success. + // + // https://github.com/apple-opensource/xnu/blob/4f43d4276fc6a87f2461a3ab18287e4a2e5a1cc0/libsyscall/wrappers/libproc/libproc.c#L100-L110 + // https://git.lix.systems/lix-project/lix/issues/446#issuecomment-5483 + // FB14695751 if (fdBufSize <= 0) { - throw SysError("Listing pid %1% file descriptors", pid); + if (errno == 0) { + break; + } else { + throw SysError("Listing pid %1% file descriptors", pid); + } } } fds.resize(fdBufSize / sizeof(struct proc_fdinfo)); |