arman@oahu.cs.ucla.edu (Arman Bostani) (09/18/89)
Pardon me if this question has been asked already ... I have been trying to get asynchronous I/O with streams working on sys-V to no avail. I have written a small program doing async. I/O with streams that works perfectly fine on a Sun-3 running 4.0.3. The program works by performing an I_SETSIG ioctl operation on stdin. When I have tried it on a couple of boxes running sys-V rel. 3.2, however, the ioctl returns an EINVAL (invalid argument) error. The streamio(7) manual has a little blurb about the fact that one will recieve an EINVAL if the file descriptor "is linked below a multiplexer". Has anyone seen this problem before? Is it possible at all to do async. I/O on ttys? If so, how does one go about it? I have included the text of a small program which runs into the problem mentioned above. Thanx for the help, arman. --------------------------------- #include <fcntl.h> #include <signal.h> #include <stropts.h> #include <stdio.h> #if defined(FNDELAY) # define NODELAY FNDELAY #elif defined(O_NDELAY) # define NODELAY O_NDELAY #else CROAK #endif #ifndef SIGPOLL # define SIGPOLL SIGIO #endif static int flags; /* * Called when we get a SIGPOLL. We read available input and spit it * out in hex. */ handler() { int c; fprintf(stderr, "got signal ...\n"); while((c = getchar()) != EOF) { fprintf(stderr, "char == 0x%x\n", c); } } bye() { fcntl(0, F_SETFL, flags &= ~NODELAY); /* reset to blocking I/O */ exit(0); } main() { /* asynchronous I/O interrpt handler */ signal(SIGPOLL, handler); /* reset to blocking mode and exit on intr, quit */ signal(SIGINT, bye); signal(SIGQUIT, bye); /* * put stdin in non-blocking mode. */ flags = fcntl(0, F_GETFL); fcntl(0, F_SETFL, flags |= NODELAY); /* * request SIGPOLL when input is available */ if (ioctl( 0, I_SETSIG, S_INPUT ) < 0) { perror("ioctl"); exit(1); } printf("type some chars followed by a carriage return to test.\n"); printf("type interrupt key to exit.\n"); /* loop forever, waiting for SIGPOLLs */ for (;;) ; } -- Arman Bostani // UCLA Computer Science Department -- arman@CS.UCLA.EDU // ...!(ucbvax,rutgers)!ucla-cs!arman
scjones@sdrc.UUCP (Larry Jones) (09/19/89)
In article <27197@shemp.CS.UCLA.EDU>, arman@oahu.cs.ucla.edu (Arman Bostani) writes: > I have been trying to get asynchronous I/O with streams working on > sys-V to no avail. I have written a small program doing async. I/O > with streams that works perfectly fine on a Sun-3 running 4.0.3. The > program works by performing an I_SETSIG ioctl operation on stdin. > > [...] > > Has anyone seen this problem before? > Is it possible at all to do async. I/O on ttys? > If so, how does one go about it? Aha, there's the problem! ttys are not stream devices in Sys V.3, so stream operations naturally don't work on them. This is supposed to be fixed in Release 4, I believe. ---- Larry Jones UUCP: uunet!sdrc!scjones SDRC scjones@SDRC.UU.NET 2000 Eastman Dr. BIX: ltl Milford, OH 45150-2789 AT&T: (513) 576-2070 "I have plenty of good sense. I just choose to ignore it." -Calvin
jgh@root.co.uk (Jeremy G Harris) (09/22/89)
In article <811@sdrc.UUCP> scjones@sdrc.UUCP (Larry Jones) writes: >Aha, there's the problem! ttys are not stream devices in Sys >V.3, so stream operations naturally don't work on them. Whether ttys are Streams devices or not depends entirely on where you obtained your V.3 from. Jeremy -- Jeremy Harris jgh@root.co.uk