mirror of
https://github.com/boykopovar/AnyPS5.git
synced 2026-11-08 13:50:20 +00:00
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:
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;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user