home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / sys / sgi / 16689 < prev    next >
Encoding:
Text File  |  1992-11-20  |  2.0 KB  |  60 lines

  1. Path: sparky!uunet!olivea!hal.com!darkstar.UCSC.EDU!cats.ucsc.edu!mmcohen
  2. From: mmcohen@cats.ucsc.edu (Michael M Cohen)
  3. Newsgroups: comp.sys.sgi
  4. Subject: Re: tty query
  5. Message-ID: <1eiok9INN9l6@darkstar.UCSC.EDU>
  6. Date: 20 Nov 92 13:19:05 GMT
  7. References: <1ei0hrINN3om@darkstar.UCSC.EDU>
  8. Organization: University of California; Santa Cruz
  9. Lines: 48
  10. NNTP-Posting-Host: si.ucsc.edu
  11.  
  12.  
  13. In article <1ei0hrINN3om@darkstar.UCSC.EDU> mmcohen@cats.ucsc.edu (Michael M Cohen) writes:
  14. >
  15. >Within a C or f77 program, wondering how to temporarily switch
  16. >whatever tty i'm on to mode which will cause getc to return immediately
  17. >if nothing has been entered. I want to do some activity
  18. >until a key press, then go back to usual tty mode.
  19. >Code fragments or pointers appreciated...
  20. >
  21.  
  22. Well, since no one responded in the last hour or so I had to
  23. hack up some code to get it done. But there is a small
  24. mystery I can't figure out. After the code is executed
  25. ^C does not act to interrupt program unless one includes
  26. final "stty" line. Question is why?
  27. ---------------------------------------
  28.  
  29. struct termio sert;
  30. tcflag_t slf;
  31.  
  32. ....
  33.         ioctl(0, TCGETA, &sert);
  34.           slf = sert.c_lflag;
  35.           sert.c_lflag &= ~(ICANON|ISIG|ECHO);
  36.           sert.c_cc[VMIN] = 0;
  37.           sert.c_cc[VTIME] = 0;
  38.         ioctl(0, TCSETA, &sert);
  39.     while(getchar() != 'd'){
  40.  
  41. ... PLAY SOME SOUNDS... 
  42.  
  43.           }
  44.  
  45.           sert.c_lflag = slf;
  46.           sert.c_cc[VMIN] = 1;
  47.           sert.c_cc[VTIME] = 1;
  48.         ioctl(0, TCSETA, &sert);
  49.     system("stty intr '\03'");  /* WHY IS THIS NEEDED ??? */
  50. ...
  51. -- 
  52.  
  53. ======================================================================
  54. =   Dr. Michael M. Cohen                   mmcohen@dewi.ucsc.edu     = 
  55. =   Program in Experimental Psychology     mmcohen@fuzzy.ucsc.edu    =
  56. =   433 Clark Kerr Hall                    408-459-2655 LAB          = 
  57. =   University of California - Santa Cruz  408-459-2700 MSGS         = 
  58. =   Santa Cruz, CA 95064                   408-459-3519 FAX          = 
  59. ======================================================================
  60.