Thread View: pe.cust.wanted
2 messages
2 total messages
Started by Tim Pointing
Thu, 28 Mar 1985 13:24
inputpending() works fine here
Author: Tim Pointing
Date: Thu, 28 Mar 1985 13:24
Date: Thu, 28 Mar 1985 13:24
66 lines
2313 bytes
2313 bytes
I tried the version of inputpending posted recently by Dave Sherman (dave@lsuc)
and, after making the 0140000 <=> UBASE correction and including <sys/tty.h>
(required for FIOCLEX), inputpending worked just fine. I have confidence that
this is not due to the modified tty driver that we are running here. Included
below is the exact source for the test that I ran...
> main()
> {
> while(1)
> {
> if(inputpending())
> printf("something\n");
> else
> printf("nothing\n");
> sleep(1);
> }
> }
>
> #include <sys/param.h>
> #include <sys/dir.h>
> #include <sys/user.h>
> #include <sys/tty.h>
>
> inputpending()
> {
> static int fd = -2;
> unsigned c;
>
> if (fd == -2) /* uninitialized */
> if ((fd = open("/dev/kmem", 0)) >= 0) {
> /* If the open fails, fd will be -1, so we won't
> * try again.
> * Close the file descriptor on exec.
> */
> ioctl(fd, FIOCLEX, (struct sgttyb *) 0);
> /*
> * u_ttyp is the pointer to the tty struct
> */
> lseek(fd, (long) &((struct user *) UBASE)->u_ttyp, 0);
> read(fd, &c, sizeof c);
> /* seek to the beginning of the tty struct */
> lseek(fd, (long) c, 0);
> }
> if (fd < 0)
> return 0;
> /* the first int of the tty struct is a pointer to the clist */
> if (read(fd, &c, sizeof c) < sizeof c)
> return 0;
> lseek(fd, - (long) sizeof c, 1);
> /* there is input when the pointer to the clist is != 0 */
> return c != 0;
> }
Hope this works for you.
Dave - is this not exactly what you have?
For those lucky enough to have source, you can very easily add an ioctl call
similar to the Berkley FIONREAD, as we have done here, which functions for
tty's. If anybody wants that code, drop me a line - its only a couple of lines
of code.
---
Tim Pointing, DCIEM
{utzoo!dciem,lsuc,pesnta}!per!tim
Re: inputpending() works fine here
Author: David Sherman
Date: Fri, 29 Mar 1985 17:37
Date: Fri, 29 Mar 1985 17:37
10 lines
910 bytes
910 bytes
I tried Tim's version (it was identical to what I'd tried
previously) and no, it doesn't work.... or am I missing something?
I run a.out, it prints a succession of nothings, I type some junk
at the terminal, and still nothings, no somethings! I press RETURN,
and still nothings...
Dave Sherman
--
{utzoo pesnta nrcaero utcs hcr}!lsuc!dave
{allegra decvax ihnp4 linus}!utcsri!lsuc!dave
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads