diff --git a/sandboxed_api/sandbox2/monitor_unotify.cc b/sandboxed_api/sandbox2/monitor_unotify.cc index 80a39d3..3d0aefc 100644 --- a/sandboxed_api/sandbox2/monitor_unotify.cc +++ b/sandboxed_api/sandbox2/monitor_unotify.cc @@ -203,9 +203,21 @@ void UnotifyMonitor::Run() { } } if (wait_for_sandboxee) { - int timeout_ms = 1000; // 1 sec - PCHECK(poll(pfds, 1, timeout_ms) != -1); - if (pfds[0].revents & POLLIN) { + absl::Time deadline = absl::Now() + absl::Seconds(1); + int ret = 0; + do { + absl::Duration remaining = deadline - absl::Now(); + if (remaining <= absl::ZeroDuration()) { + ret = 0; + break; + } + ret = + poll(pfds, 1, static_cast(absl::ToInt64Milliseconds(remaining))); + } while (ret == -1 && errno == EINTR); + PCHECK(ret != -1); + if (ret == 0) { + LOG(WARNING) << "Waiting for sandboxee exit timed out"; + } else if (pfds[0].revents & POLLIN) { SetExitStatusFromStatusPipe(); } else if (pfds[0].revents & POLLHUP) { SetExitStatusCode(Result::INTERNAL_ERROR, Result::FAILED_MONITOR);