+void maybe_sigio_broken(int fd, int read)
+{
+ int err;
+
+ if(!isatty(fd))
+ return;
+
+ if((read || pty_output_sigio) && (!read || pty_close_sigio))
+ return;
+
+ write_sigio_workaround();
+
+ sigio_lock();
+ err = need_poll(&all_sigio_fds, all_sigio_fds.used + 1);
+ if(err)
+ goto out;
+
+ all_sigio_fds.poll[all_sigio_fds.used++] =
+ ((struct pollfd) { .fd = fd,
+ .events = read ? POLLIN : POLLOUT,
+ .revents = 0 });
+out:
+ sigio_unlock();
+}
+
+static void sigio_cleanup(void)