summaryrefslogtreecommitdiff
path: root/sshpty.c
diff options
context:
space:
mode:
authormouring <mouring>2001-08-06 23:29:16 +0000
committermouring <mouring>2001-08-06 23:29:16 +0000
commit8d3572c8642ca7f8ecc60871f5347712b779e25f (patch)
tree7dfc9743ef7f864afc0b969d1a2855d9fc7a37d0 /sshpty.c
parent3bea9e709f19f65267d5cabc7aaf31bd07a4d3a5 (diff)
downloadopenssh-8d3572c8642ca7f8ecc60871f5347712b779e25f.tar.gz
- (bal) Second around of UNICOS patches. A few other things left.
Patches by William L. Jones <jones@mail.utexas.edu>
Diffstat (limited to 'sshpty.c')
-rw-r--r--sshpty.c59
1 files changed, 59 insertions, 0 deletions
diff --git a/sshpty.c b/sshpty.c
index 71e16b79..84572c90 100644
--- a/sshpty.c
+++ b/sshpty.c
@@ -162,6 +162,34 @@ pty_allocate(int *ptyfd, int *ttyfd, char *namebuf, int namebuflen)
}
return 1;
#else /* HAVE_DEV_PTS_AND_PTC */
+#ifdef _CRAY
+ char buf[64];
+ int i;
+ int highpty;
+
+#ifdef _SC_CRAY_NPTY
+ highpty = sysconf(_SC_CRAY_NPTY);
+ if (highpty == -1)
+ highpty = 128;
+#else
+ highpty = 128;
+#endif
+
+ for (i = 0; i < highpty; i++) {
+ snprintf(buf, sizeof(buf), "/dev/pty/%03d", i);
+ *ptyfd = open(buf, O_RDWR|O_NOCTTY);
+ if (*ptyfd < 0) continue;
+ snprintf(namebuf, namebuflen, "/dev/ttyp%03d", i);
+ /* Open the slave side. */
+ *ttyfd = open(namebuf, O_RDWR|O_NOCTTY);
+ if (*ttyfd < 0) {
+ error("%.100s: %.100s", namebuf, strerror(errno));
+ close(*ptyfd);
+ }
+ return 1;
+ }
+ return 0;
+#else
/* BSD-style pty code. */
char buf[64];
int i;
@@ -196,6 +224,7 @@ pty_allocate(int *ptyfd, int *ttyfd, char *namebuf, int namebuflen)
return 1;
}
return 0;
+#endif /* CRAY */
#endif /* HAVE_DEV_PTS_AND_PTC */
#endif /* HAVE_DEV_PTMX */
#endif /* HAVE__GETPTY */
@@ -218,6 +247,35 @@ pty_release(const char *ttyname)
void
pty_make_controlling_tty(int *ttyfd, const char *ttyname)
{
+#ifdef _CRAY
+ int fd;
+
+ if (setsid() < 0)
+ error("setsid: %.100s", strerror(errno));
+
+ fd = open(ttyname, O_RDWR|O_NOCTTY);
+ if (fd >= 0) {
+ signal(SIGHUP, SIG_IGN);
+ ioctl(fd, TCVHUP, (char *)0);
+ signal(SIGHUP, SIG_DFL);
+ setpgid(0,0);
+ close(fd);
+ } else {
+ error("Failed to disconnect from controlling tty.");
+ }
+
+
+ debug("Setting controlling tty using TCSETCTTY.\n");
+ ioctl(*ttyfd, TCSETCTTY, NULL);
+
+ fd = open("/dev/tty", O_RDWR);
+
+ if (fd < 0)
+ error("%.100s: %.100s", ttyname, strerror(errno));
+
+ close(*ttyfd);
+ *ttyfd = fd;
+#else
int fd;
#ifdef USE_VHANGUP
void *old;
@@ -277,6 +335,7 @@ pty_make_controlling_tty(int *ttyfd, const char *ttyname)
else {
close(fd);
}
+#endif
}
/* Changes the window size associated with the pty. */