diff --git a/src/timer.c b/src/timer.c index 9408fe0..155e78f 100644 --- a/src/timer.c +++ b/src/timer.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -490,21 +491,29 @@ static void int_timer_init() void int_io_open(int fd) { + DBPRINT(("int_io_open %d\n", fd)); #ifdef DOS /* would turn on DOS kbd signal handler here */ -#elseif defined(O_ASYNC) - DBPRINT(("int_io_opening %d\n", fd)); +#elif defined(O_ASYNC) if (fcntl(fd, F_SETOWN, getpid()) == -1) perror("fcntl F_SETOWN error"); if (fcntl(fd, F_SETFL, fcntl(fd, F_GETFL, 0) | O_ASYNC) == -1) perror("fcntl F_SETFL on error"); +#elif defined(FASYNC) && defined(FNDELAY) + if (fcntl(fd, F_SETOWN, getpid()) == -1) perror("fcntl F_SETOWN error"); + if (fcntl(fd, F_SETFL, fcntl(fd, F_GETFL, 0) | FNDELAY | FASYNC) == -1) perror("fcntl F_SETFL on error"); +#else +#warning "No async i/o can be enabled - investigate and remedy this" #endif } void int_io_close(int fd) { + DBPRINT(("int_io_close %d\n", fd)); #ifdef DOS /* Turn off signaller here */ -#elseif defined(O_ASYNC) +#elif defined(O_ASYNC) if (fcntl(fd, F_SETFL, fcntl(fd, F_GETFL, 0) & ~O_ASYNC) == -1) perror("fcntl_F_SETFL off error"); +#elif defined(FASYNC) && defined(FNDELAY) + if (fcntl(fd, F_SETFL, fcntl(fd, F_GETFL, 0) & ~(FNDELAY | FASYNC)) == -1) perror("fcntl F_SETFL off error"); #endif }