mirror of
https://github.com/google/sandboxed-api.git
synced 2024-03-22 13:11:30 +08:00
Fix the poll in wait_for_sandboxee branch
PiperOrigin-RevId: 516544270 Change-Id: Ibb10611b9b7713ac6513199b6213c15d22772ea5
This commit is contained in:
parent
5a2bdd436d
commit
690b31a038
|
@ -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<int>(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);
|
||||
|
|
Loading…
Reference in New Issue
Block a user