work around a kqueue bug(?) on Mac OS X

There seems to be a problem in kqueue() on Mac OS X for watching for
FIFO write availability, where adding a read event for the same FIFO
(at a different file descritor) can disable the write event.

Merge to v6.1.1
This commit is contained in:
Matthew Flatt 2014-10-26 09:20:18 -06:00
parent 2679638e74
commit a352470914

View File

@ -3739,8 +3739,12 @@ Scheme_Object *scheme_fd_to_semaphore(intptr_t fd, int mode, int is_socket)
# ifdef HAVE_KQUEUE_SYSCALL
if (!is_socket) {
if (!scheme_fd_regular_file(fd, 2))
return NULL; /* kqueue() might not work on devices, such as ttys */
/* kqueue() might not work on devices, such as ttys; also, while
Mac OS X kqueue() claims to work on FIFOs, there are problems:
watching for reads on a FIFO sometimes disables watching for
writes on the same FIFO with a different file descriptor */
if (!scheme_fd_regular_file(fd, 1))
return NULL;
}
if (scheme_semaphore_fd_kqueue < 0) {
scheme_semaphore_fd_kqueue = kqueue();