1: /* $Header$ */
   2: 
   3: /*
   4:  * Author: Peter J. Nicklin
   5:  */
   6: 
   7: /*
   8:  * isintract() determines whether a process is a foreground job, and
   9:  * standard input and output streams are connected to a terminal.
  10:  * Returns integer YES if it is, otherwise NO.
  11:  */
  12: #include <stdio.h>
  13: #include <signal.h>
  14: #include <sys/ioctl.h>
  15: #include "system.h"
  16: #include "yesno.h"
  17: 
  18: isintract()
  19: {
  20:     int intract = NO;       /* is interactive? */
  21: #ifdef V4BSD
  22:     int isatty();           /* is stream a terminal? */
  23:     int tpgrp;          /* terminal process group */
  24:     int (*tstpstat)();      /* stop signal status */
  25:     int (*ttinstat)();      /* background read status */
  26:     int (*ttoustat)();      /* background write status */
  27: 
  28:     tstpstat = signal(SIGTSTP, SIG_IGN);
  29:     ttinstat = signal(SIGTTIN, SIG_IGN);
  30:     ttoustat = signal(SIGTTOU, SIG_IGN);
  31:     if (isatty(fileno(stdin)) && isatty(fileno(stdout)))
  32:         {
  33:         ioctl(fileno(stdin), TIOCGPGRP, &tpgrp);
  34:         if (tpgrp == getpgrp(0))
  35:             intract = YES;
  36:         }
  37:     signal(SIGTSTP, tstpstat);
  38:     signal(SIGTTIN, ttinstat);
  39:     signal(SIGTTOU, ttoustat);
  40: #else
  41:     int isatty();           /* is stream a terminal? */
  42: 
  43:     if (isatty(fileno(stdin)) && isatty(fileno(stdout)))
  44:         intract = YES;
  45: #endif
  46:     return(intract);
  47: }

Defined functions

isintract defined in line 18; never used
Last modified: 1985-07-03
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 537
Valid CSS Valid XHTML 1.0 Strict