* SIGIO
@ 1997-04-29 3:52 Robert L. McMillin
0 siblings, 0 replies; only message in thread
From: Robert L. McMillin @ 1997-04-29 3:52 UTC (permalink / raw)
To: tru64-unix-managers
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 <errno.h>
#include <fcntl.h>
#include <signal.h>
#include <stdio.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~1997-04-29 3:52 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1997-04-29 3:52 SIGIO Robert L. McMillin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox