fix(libkernel): catch host watch thread errors instead of terminating

The EVFILT_VNODE host watch thread in AddVnodeEvent ran RunHostWatch
directly. RunHostWatch throws std::runtime_error on poll, inotify, kqueue
or change-notification failures, and an exception escaping a detached
std::thread calls std::terminate and aborts the whole process. The thread
entry now catches std::exception, reports the message on stderr and ends
the watch, which RunHostWatch has already closed on every throw path.
This commit is contained in:
MarcZX10 committed 2026-11-03 08:26:30 +00:00
1 parent 4f41f4c375
commit 1d87704f6a
1 file changed
+9 -1
@@ -7,6 +7,7 @@
#include <atomic>
#include <cerrno>
#include <cstdint>
#include <cstdio>
#include <memory>
#include <stdexcept>
#include <string>
@@ -770,7 +771,14 @@ int AddVnodeEvent(const KernelEqueueRef& queue, int descriptor, std::uint32_t ff
CloseHostWatch(host);
return result == EQUEUE_OK ? 0 : result & 0xffff;
}
std::thread(RunHostWatch, watch, std::move(host)).detach();
std::thread([watch, host = std::move(host)]() mutable {
try {
RunHostWatch(watch, std::move(host));
} catch (const std::exception& error) {
std::fprintf(stderr, "%s\n", error.what());
std::fflush(stderr);
}
}).detach();
return 0;
}