feat(hydra-eval-jobs.cc): add check_pid_status_nonblocking to catch handler

This commit is contained in:
Kayla Firestack 2022-04-14 11:18:29 -04:00
parent cb4fa0000f
commit 62cdbc4138

View file

@ -25,7 +25,7 @@
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
void check_pid_status_quick(pid_t check_pid) { void check_pid_status_nonblocking(pid_t check_pid) {
// Only check 'initialized' and known PID's // Only check 'initialized' and known PID's
if (check_pid <= 0) { return; } if (check_pid <= 0) { return; }
@ -333,8 +333,8 @@ int main(int argc, char * * argv)
/* Start a handler thread per worker process. */ /* Start a handler thread per worker process. */
auto handler = [&]() auto handler = [&]()
{ {
pid_t pid = -1;
try { try {
pid_t pid = -1;
AutoCloseFD from, to; AutoCloseFD from, to;
while (true) { while (true) {
@ -436,6 +436,7 @@ int main(int argc, char * * argv)
} }
} }
} catch (...) { } catch (...) {
check_pid_status_nonblocking(pid);
auto state(state_.lock()); auto state(state_.lock());
state->exc = std::current_exception(); state->exc = std::current_exception();
wakeup.notify_all(); wakeup.notify_all();