home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.sys.hp:12690 comp.unix.programmer:5216
- Newsgroups: comp.sys.hp,comp.unix.programmer
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!moe.ksu.ksu.edu!hobbes.physics.uiowa.edu!news.uiowa.edu!icaen!dsiebert
- From: dsiebert@icaen.uiowa.edu (Doug Siebert)
- Subject: How does flow control work for pseudo ttys under HP-UX?
- Message-ID: <1992Nov9.064654.9997@icaen.uiowa.edu>
- Sender: usenet@icaen.uiowa.edu (UseNet News daemon)
- Organization: ISCA
- Date: Mon, 9 Nov 1992 06:46:54 GMT
- Lines: 105
-
- Sorry if this is posted twice -- my news server was having problems when I made
- the first attempt and so far as I can tell it was never actually posted.
-
- I can't seem to figure out how flow control is supposed to work for pseudo
- ttys under HP-UX, which uses the termios struct to control pty/tty modes.
- According to the man pages, setting IXOFF should turn on input flow control,
- but this doesn't seem to work for me. I wrote a short test program to try to
- learn something, but it didn't help much. Here it is, followed by a sample of
- its output. Can anyone explain to me what is missing to make flow control
- work properly?
-
- I should be able to select on the master and slave sides, and determine when
- the input queue is full by the slave side no longer selecting for write. This
- condition nevers occurs though. It is obvious characters are being lost,
- however!
-
-
- ---cut here---
-
- #include <sys/file.h>
- #include <sys/ioctl.h>
- #include <termios.h>
-
- char bufw[256];
- char bufr[128];
-
- main()
- {
- int p,
- t;
- int w,
- r;
- int i;
- struct termios termbuf;
- fd_set rf,
- wf;
-
- p = open("/dev/ptym/ptyo0", O_RDWR);
- if (p < 0)
- perror("pty");
- t = open("/dev/pty/ttyo2", O_RDWR);
- if (t < 0)
- perror("tty");
- i = 1;
- ioctl(p, FIOSNBIO, &i);
- i = 1;
- ioctl(t, FIOSNBIO, &i);
- tcgetattr(p, &termbuf);
- termbuf.c_iflag |= IXOFF;
- termbuf.c_lflag &= ~ICANON & ~ECHO;
- tcsetattr(p, &termbuf, TCSADRAIN);
- tcgetattr(t, &termbuf);
- termbuf.c_iflag |= IXOFF;
- termbuf.c_lflag &= ~ICANON & ~ECHO;
- tcsetattr(t, &termbuf, TCSADRAIN);
- for (;;)
- {
- FD_ZERO(&rf);
- FD_ZERO(&wf);
- FD_SET(p, &wf);
- FD_SET(t, &rf);
- i = select(10, &rf, &wf, 0, 0);
- if (i < 1)
- perror("select");
- w = r = -2;
- if (FD_ISSET(p, &wf))
- w = write(p, bufw, sizeof bufw);
- if (FD_ISSET(t, &rf))
- r = read(t, bufr, sizeof bufr);
- printf("wrote %d, read %d\n", w, r);
- sleep(1);
- }
- }
-
- ---cut here---
-
-
- Here is the output of a run of this program:
-
- # ./test
- wrote 256, read -2
- wrote 256, read 128
- wrote 256, read 128
- wrote 256, read 128
- wrote 256, read 126
- wrote 256, read -2
- wrote 256, read 128
- wrote 256, read 128
- wrote 256, read 128
- wrote 256, read 126
- wrote 256, read -2
-
- [...and so on...]
-
-
- Can anyone tell me what I am missing here? It *should* work, according to TFM,
- but it doesn't. Any help out there?
-
- --
- /-----------------------------------------------------------------------------\
- | Doug Siebert | "I don't have to take this abuse |
- | Internet: dsiebert@isca.uiowa.edu | from you - I've got hundreds of |
- | NeXTMail: dsiebert@chop.isca.uiowa.edu | people waiting in line to abuse |
- | ICBM: 41d 39m 55s N, 91d 30m 43s W | me!" Bill Murray, Ghostbusters |
- \-----------------------------------------------------------------------------/
-