Date: Wed, 13 Nov 1996 19:16:18 +1100 From: Bruce Evans <bde@zeta.org.au> To: hackers@freebsd.org, jkh@time.cdrom.com Subject: Re: Is our ASYNC I/O support for ttys broken? Message-ID: <199611130816.TAA28631@godzilla.zeta.org.au>
next in thread | raw e-mail | index | archive | help
>Thomas Roell over at X Inside just sent me this little snippet, >complaining that ASYNC I/O was broken in FreeBSD where it worked with >Linux and SVR4. Any comments? The status hasn't changed since he complained a year or so ago. SIGIO for ASYNC tty i/o is only sent to the process group of the tty, and process group stuff is limited by it being POSIX conformant with few extensions - the process group can not be changed using F_SETOWN (although F_SETOWN takes you outside of POSIX) unless the corresponding change using tcsetpgrp() would work. SIGIO for ASYNC socket i/o works better because the process or process group of the socket, and this is unrelated to the POSIX process group. > fd = open("/dev/ttyd0", O_RDONLY | O_NONBLOCK); > > fcntl(fd, F_SETFL, fcntl(fd, F_GETFL, 0) | FASYNC); > fcntl(fd, F_SETOWN, getpid()); The second fcntl is guaranteed to fail, since `fd' isn't a controlling terminal. To make fd a controlling terminal, something like the following must be done: fork() wait in parent, continue as follows in child: setsid(); /* become a session leader with no ctty */ open as above first fcntl as above ioctl(fd, TIOCSCTTY, NULL); /* make fd the ctty */ second fcntl as above Bruce
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199611130816.TAA28631>