From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <96078611110715.tru64-unix-managers.marc@archive.invalid> From: "Robert L. McMillin" Date: Tue, 29 Apr 1997 03:52:02 +0000 To: tru64-unix-managers Subject: SIGIO X-MARC-Message: https://marc.info/?l=tru64-unix-managers&m=96078611110715 Has anyone had any experience with the SIGIO signal? I really can't seem to find that much documentation on it. (It's not even mentioned in in the O'Reilly Posix docs.) It seems to me that I ought to get a SIGIO when any open input fd has data for me. In the program below, the device '/dev/wwvb1' is softlinked to /dev/tty00, which has a GPS-driven serial clock attached to it. Output from this clock occurs at one second intervals. (I have verified this by doing a 'cat /dev/wwvb1'.) So... if I run this program for five seconds, I should expect to see an output of 'caught 5 interrupts' -- but it always tells me it caught none. Is there something I'm missing? -------- snip snip -------- #include #include #include #include #include #include #include int fd; int interrupt_counter=3D0; void sigio_handler(sig) int sig; { interrupt_counter++; } =0C static void exit_handler(void) { sigset(SIGIO,SIG_DFL); printf ("caught %d interrupts\n",interrupt_counter); exit(0); } =0C static void set_signal(void) { int n; struct sigaction vec; sigemptyset(&vec.sa_mask); sigaddset(&vec.sa_mask, SIGIO); vec.sa_flags =3D 0; vec.sa_handler =3D sigio_handler; while (1) { n =3D sigaction(SIGIO, &vec, NULL); if (n =3D=3D -1 && errno =3D=3D EINTR) continue; break; } if (n =3D=3D -1) { perror("sigaction"); exit(1); } sigemptyset(&vec.sa_mask); sigaddset(&vec.sa_mask, SIGINT); vec.sa_flags =3D 0; vec.sa_handler =3D exit_handler; n =3D sigaction(SIGINT,&vec,NULL); if (n =3D=3D -1) { perror("sigaction(2)"); exit(1); } } main() { fd =3D open ("/dev/wwvb1",O_RDONLY|O_NONBLOCK); if (fd =3D=3D -1) { printf ("unable to open /dev/wwvb1, bye\n"); exit(1); } set_signal(); while(1) { pause(); } } -------- snip, snip -------- --=20 Robert L. McMillin | Not the voice of Syseca, Inc. | rlm@syseca-us.com Personal: rlm@helen.surfcty.com |=A0rlm@netcom.com