Date: Tue, 12 Nov 1996 16:04:01 -0800 From: "Jordan K. Hubbard" <jkh@time.cdrom.com> To: hackers@freebsd.org Subject: Is our ASYNC I/O support for ttys broken? Message-ID: <29402.847843441@time.cdrom.com>
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?
#include <stdio.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/signal.h>
int fd;
void
signal_handler(
int signo
)
{
char buf[64];
printf("bazoing %d\n", read(fd, buf, sizeof(buf)));
}
main()
{
struct sigaction sa;
sa.sa_handler = signal_handler;
sa.sa_flags = SA_RESTART;
sigemptyset(&sa.sa_mask);
sigaction(SIGIO, &sa, NULL);
fd = open("/dev/ttyd0", O_RDONLY | O_NONBLOCK);
fcntl(fd, F_SETFL, fcntl(fd, F_GETFL, 0) | FASYNC);
fcntl(fd, F_SETOWN, getpid());
for (;;) { sleep(10000); }
}
And yes indeed, the signal handler never goes off when you're trying
to talk to a standard TTY device. I changed the /dev/ttyd0 in the
example to /dev/cuaa1, which is where my mouse is (and from which I
can provably read data with cat) and the signal handler was never
called.
Jordan
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?29402.847843441>
