[BACK]Return to pty.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / ssh

Diff for /src/usr.bin/ssh/Attic/pty.c between version 1.7 and 1.8

version 1.7, 1999/11/24 00:26:02 version 1.8, 1999/11/24 19:53:48
Line 28 
Line 28 
 #define O_NOCTTY 0  #define O_NOCTTY 0
 #endif  #endif
   
 /* Allocates and opens a pty.  Returns 0 if no pty could be allocated,  /*
    or nonzero if a pty was successfully allocated.  On success, open file   * Allocates and opens a pty.  Returns 0 if no pty could be allocated, or
    descriptors for the pty and tty sides and the name of the tty side are   * nonzero if a pty was successfully allocated.  On success, open file
    returned (the buffer must be able to hold at least 64 characters). */   * descriptors for the pty and tty sides and the name of the tty side are
    * returned (the buffer must be able to hold at least 64 characters).
    */
   
 int  int
 pty_allocate(int *ptyfd, int *ttyfd, char *namebuf)  pty_allocate(int *ptyfd, int *ttyfd, char *namebuf)
Line 48 
Line 50 
         return 1;          return 1;
 #else /* HAVE_OPENPTY */  #else /* HAVE_OPENPTY */
 #ifdef HAVE__GETPTY  #ifdef HAVE__GETPTY
         /* _getpty(3) exists in SGI Irix 4.x, 5.x & 6.x -- it generates          /*
            more pty's automagically when needed */           * _getpty(3) exists in SGI Irix 4.x, 5.x & 6.x -- it generates more
            * pty's automagically when needed
            */
         char *slave;          char *slave;
   
         slave = _getpty(ptyfd, O_RDWR, 0622, 0);          slave = _getpty(ptyfd, O_RDWR, 0622, 0);
Line 68 
Line 72 
         return 1;          return 1;
 #else /* HAVE__GETPTY */  #else /* HAVE__GETPTY */
 #ifdef HAVE_DEV_PTMX  #ifdef HAVE_DEV_PTMX
         /* This code is used e.g. on Solaris 2.x.  (Note that Solaris 2.3          /*
            also has bsd-style ptys, but they simply do not work.) */           * This code is used e.g. on Solaris 2.x.  (Note that Solaris 2.3
            * also has bsd-style ptys, but they simply do not work.)
            */
         int ptm;          int ptm;
         char *pts;          char *pts;
   
Line 99 
Line 105 
                 close(*ptyfd);                  close(*ptyfd);
                 return 0;                  return 0;
         }          }
         /* Push the appropriate streams modules, as described in Solaris          /* Push the appropriate streams modules, as described in Solaris pts(7). */
            pts(7). */  
         if (ioctl(*ttyfd, I_PUSH, "ptem") < 0)          if (ioctl(*ttyfd, I_PUSH, "ptem") < 0)
                 error("ioctl I_PUSH ptem: %.100s", strerror(errno));                  error("ioctl I_PUSH ptem: %.100s", strerror(errno));
         if (ioctl(*ttyfd, I_PUSH, "ldterm") < 0)          if (ioctl(*ttyfd, I_PUSH, "ldterm") < 0)
Line 134 
Line 139 
         /* BSD-style pty code. */          /* BSD-style pty code. */
         char buf[64];          char buf[64];
         int i;          int i;
         const char *ptymajors =          const char *ptymajors = "pqrstuvwxyzabcdefghijklmnoABCDEFGHIJKLMNOPQRSTUVWXYZ";
         "pqrstuvwxyzabcdefghijklmnoABCDEFGHIJKLMNOPQRSTUVWXYZ";  
         const char *ptyminors = "0123456789abcdef";          const char *ptyminors = "0123456789abcdef";
         int num_minors = strlen(ptyminors);          int num_minors = strlen(ptyminors);
         int num_ptys = strlen(ptymajors) * num_minors;          int num_ptys = strlen(ptymajors) * num_minors;
Line 194 
Line 198 
         if (setsid() < 0)          if (setsid() < 0)
                 error("setsid: %.100s", strerror(errno));                  error("setsid: %.100s", strerror(errno));
   
         /* Verify that we are successfully disconnected from the          /*
            controlling tty. */           * Verify that we are successfully disconnected from the controlling
            * tty.
            */
         fd = open("/dev/tty", O_RDWR | O_NOCTTY);          fd = open("/dev/tty", O_RDWR | O_NOCTTY);
         if (fd >= 0) {          if (fd >= 0) {
                 error("Failed to disconnect from controlling tty.");                  error("Failed to disconnect from controlling tty.");
Line 204 
Line 210 
         /* Make it our controlling tty. */          /* Make it our controlling tty. */
 #ifdef TIOCSCTTY  #ifdef TIOCSCTTY
         debug("Setting controlling tty using TIOCSCTTY.");          debug("Setting controlling tty using TIOCSCTTY.");
         /* We ignore errors from this, because HPSUX defines TIOCSCTTY,          /*
            but returns EINVAL with these arguments, and there is           * We ignore errors from this, because HPSUX defines TIOCSCTTY, but
            absolutely no documentation. */           * returns EINVAL with these arguments, and there is absolutely no
            * documentation.
            */
         ioctl(*ttyfd, TIOCSCTTY, NULL);          ioctl(*ttyfd, TIOCSCTTY, NULL);
 #endif /* TIOCSCTTY */  #endif /* TIOCSCTTY */
         fd = open(ttyname, O_RDWR);          fd = open(ttyname, O_RDWR);

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.8