diff --git a/libs/pbd/system_exec.cc b/libs/pbd/system_exec.cc index 61670917d5..b199f8aa13 100644 --- a/libs/pbd/system_exec.cc +++ b/libs/pbd/system_exec.cc @@ -836,16 +836,27 @@ SystemExec::output_interposer () for (;fcntl (rfd, F_GETFL) != -1;) { r = read (rfd, buf, BUFSIZ - 1); if (r < 0 && (errno == EINTR || errno == EAGAIN)) { + +#ifdef __APPLE__ again: +#endif /* wait till ready to read */ - struct pollfd pfd; pfd.fd = rfd; pfd.events = POLLIN|POLLERR|POLLHUP|POLLNVAL; +#ifdef __APPLE__ + /* on macOS poll() will not return when the pipe + * is closed in an EOF state. + * Work around with a timeout and fail next time + * when with POLLNVAL. + */ int rv = poll (&pfd, 1, 1000); +#else + int rv = poll (&pfd, 1, -1); +#endif if (rv == -1) { break; @@ -859,10 +870,12 @@ again: /* back to read(2) call */ continue; } +#ifdef __APPLE__ if (rv == 0) { /* Timeout, poll again */ goto again; } +#endif } if (r <= 0) { break;