38a39,40 > #include > #include 125a128 > char *pty(int *ptyv); 171a175 > char *pty(); 1477,1479c1481 < signal(SIGPIPE, CatchPipeSignal); < pipe(to_prog); < pipe(from_prog); --- > char *ttyname; 1480a1483,1490 > if ((ttyname = pty(&to_prog[1])) == (char *) NULL) { > perror(program_name); > exit(1); > } > > from_prog[0] = to_prog[1]; > to_prog[0] = from_prog[1] = open(ttyname, O_RDWR, 0); > 2374a2385,2538 > } > > #define FIRST_PTY_LETTER 'p' > #define SYSV_PTYS > > /* Open an available pty, putting descriptor in *ptyv, > and return the file name of the pty. Return 0 if none available. */ > > char ptyname[24]; > > char * > pty (ptyv) > int *ptyv; > { > struct stat stb; > register c, i; > > #ifdef PTY_ITERATION > PTY_ITERATION > #else > for (c = FIRST_PTY_LETTER; c <= 'z'; c++) > for (i = 0; i < 16; i++) > #endif > { > #ifdef PTY_NAME_SPRINTF > PTY_NAME_SPRINTF > #else > #ifdef HPUX > sprintf (ptyname, "/dev/ptym/pty%c%x", c, i); > #else > #ifdef RTU > sprintf (ptyname, "/dev/pty%x", i); > #else > sprintf (ptyname, "/dev/pty%c%x", c, i); > #endif /* not RTU */ > #endif /* not HPUX */ > #endif /* no PTY_NAME_SPRINTF */ > > #ifndef IRIS > if (stat (ptyname, &stb) < 0) > return 0; > *ptyv = open (ptyname, O_RDWR | O_NDELAY, 0); > #else /* Unusual IRIS code */ > *ptyv = open ("/dev/ptc", O_RDWR | O_NDELAY, 0); > if (*ptyv < 0) > return 0; > if (fstat (*ptyv, &stb) < 0) > return 0; > #endif /* IRIS */ > > if (*ptyv >= 0) > { > /* check to make certain that both sides are available > this avoids a nasty yet stupid bug in rlogins */ > #ifdef PTY_TTY_NAME_SPRINTF > PTY_TTY_NAME_SPRINTF > #else > /* In version 19, make these special cases use the macro above. */ > #ifdef HPUX > sprintf (ptyname, "/dev/pty/tty%c%x", c, i); > #else > #ifdef RTU > sprintf (ptyname, "/dev/ttyp%x", i); > #else > #ifdef IRIS > sprintf (ptyname, "/dev/ttyq%d", minor (stb.st_rdev)); > #else > sprintf (ptyname, "/dev/tty%c%x", c, i); > #endif /* not IRIS */ > #endif /* not RTU */ > #endif /* not HPUX */ > #endif /* no PTY_TTY_NAME_SPRINTF */ > #ifndef UNIPLUS > if (access (ptyname, 6) != 0) > { > close (*ptyv); > #ifndef IRIS > continue; > #else > return (0); > #endif /* IRIS */ > } > #endif /* not UNIPLUS */ > /* > * If the following statement is included, > * then a 0 length record is EOT, but no other > * control characters can be sent down the pty > * (e.g., ^S/^Q, ^O, etc.). If it is not > * included, then sending ^D down the pty-pipe > * makes a pretty good EOF. > */ > /* I'm told that TOICREMOTE does not mean control chars > "can't be sent" but rather that they don't have > input-editing or signaling effects. > That should be good, because we have other ways > to do those things in Emacs. > However, telnet mode seems not to work on 4.2. > So TIOCREMOTE is turned off now. */ > > /* Under hp-ux, if TIOCREMOTE is turned on, some calls > will hang. In particular, the "timeout" feature (which > causes a read to return if there is no data available) > does this. Also it is known that telnet mode will hang > in such a way that Emacs must be stopped (perhaps this > is the same problem). > > If TIOCREMOTE is turned off, then there is a bug in > hp-ux which sometimes loses data. Apparently the > code which blocks the master process when the internal > buffer fills up does not work. Other than this, > though, everything else seems to work fine. > > Since the latter lossage is more benign, we may as well > lose that way. -- cph */ > #ifdef HPUX > #if 0 > #define DID_REMOTE > ioctl (*ptyv, TIOCREMOTE, 1); > /* Yes, HPUX has an incompatible interface for this. > Also, using it makes telnet.el fail (Emacs hangs sending text to > it). */ > #endif > #else /* not HPUX */ > #if 0 > #ifdef TIOCREMOTE > { > int on = 1; > ioctl (*ptyv, TIOCREMOTE, &on); > } > #endif > #endif > #endif /* not HPUX */ > /* this is said to be unecessary, and to be harmful in 4.3. */ > /* ioctl (*ptyv, FIONBIO, &on); */ > #ifdef FIONBIO > #ifdef SYSV_PTYS > { > int on = 1; > ioctl (*ptyv, FIONBIO, &on); > } > #endif > #endif > #ifdef IBMRTAIX > /* On AIX, the parent gets SIGHUP when a pty attached child dies. So, we */ > /* ignore SIGHUP once we've started a child on a pty. Note that this may */ > /* cause EMACS not to die when it should, i.e., when its own controlling */ > /* tty goes away. I've complained to the AIX developers, and they may */ > /* change this behavior, but I'm not going to hold my breath. */ > signal (SIGHUP, SIG_IGN); > #endif > return ptyname; > } > } > return 0;