Fix endless poll on macOS #8753
Harvid daemonizes and does not write anything to stdout/err. as opposed to select(), poll() on macOS does not return when the child process terminates or is killed. However poll() on an invalid FD does throw an error and POLLNVAL is set.
This commit is contained in:
parent
e7466bddbc
commit
f4166fb61d
@ -836,21 +836,22 @@ SystemExec::output_interposer ()
|
||||
for (;fcntl (rfd, F_GETFL) != -1;) {
|
||||
r = read (rfd, buf, BUFSIZ - 1);
|
||||
if (r < 0 && (errno == EINTR || errno == EAGAIN)) {
|
||||
again:
|
||||
|
||||
/* wait till ready to read */
|
||||
|
||||
struct pollfd pfd;
|
||||
|
||||
pfd.fd = rfd;
|
||||
pfd.events = POLLIN|POLLERR|POLLHUP;
|
||||
pfd.events = POLLIN|POLLERR|POLLHUP|POLLNVAL;
|
||||
|
||||
int rv = poll (&pfd, 1, -1);
|
||||
int rv = poll (&pfd, 1, 1000);
|
||||
|
||||
if (rv == -1) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (pfd.revents & (POLLERR|POLLHUP)) {
|
||||
if (pfd.revents & (POLLERR|POLLHUP|POLLNVAL)) {
|
||||
break;
|
||||
}
|
||||
|
||||
@ -858,6 +859,10 @@ SystemExec::output_interposer ()
|
||||
/* back to read(2) call */
|
||||
continue;
|
||||
}
|
||||
if (rv == 0) {
|
||||
/* Timeout, poll again */
|
||||
goto again;
|
||||
}
|
||||
}
|
||||
if (r <= 0) {
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user