home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume2 / window / part4 / tstp.c.new < prev    next >
Encoding:
Text File  |  1986-11-30  |  841 b   |  40 lines

  1. # include    <signal.h>
  2.  
  3. # include    "curses.ext"
  4.  
  5. /*
  6.  * handle stop and start signals
  7.  *
  8.  * 6/25/83 (Berkeley) @(#)tstp.c    1.3
  9.  */
  10. tstp() {
  11.  
  12. # ifdef SIGTSTP
  13.  
  14.     int ttyflags;
  15.     int    omask;
  16. # ifdef DEBUG
  17.     if (outf)
  18.         fflush(outf);
  19. # endif
  20.     ttyflags = _tty.sg_flags;    /* store curses state */
  21.     mvcur(0, COLS - 1, LINES - 1, 0);
  22.     endwin();
  23.     fflush(stdout);
  24.     /* reset signal handler so kill below stops us */
  25.     signal(SIGTSTP, SIG_DFL);
  26. #define    mask(s)    (1 << ((s)-1))
  27.     omask = sigsetmask(sigblock(0) &~ mask(SIGTSTP));
  28.     kill(0, SIGTSTP);
  29.     /* pc stops here */
  30.     /* okay, we started up again. */
  31.     sigsetmask(omask);
  32.     signal(SIGTSTP, tstp);
  33.     savetty();    /* re-remember the virgin state */
  34.     _tty.sg_flags = ttyflags;    /* restore special curses state */
  35.     ioctl(_tty_ch, TIOCSETN, &_tty);
  36.     _puts(TI); /* should we do VS too? */
  37.     wrefresh(curscr);
  38. # endif    SIGTSTP
  39. }
  40.