summaryrefslogtreecommitdiff
path: root/sshpty.c
diff options
context:
space:
mode:
authorBen Lindstrom <mouring@eviladmin.org>2001-08-06 23:29:16 +0000
committerBen Lindstrom <mouring@eviladmin.org>2001-08-06 23:29:16 +0000
commit6db66ff3877f52110cda3104e798d91091af7200 (patch)
tree29ce760512a91bdd7bdc6a7961e3d851404afeff /sshpty.c
parentff2866cf5198be7669423641538bb910080ee029 (diff)
- (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 71e16b79e..84572c901 100644
--- a/sshpty.c
+++ b/sshpty.c
@@ -162,6 +162,34 @@ pty_allocate(int *ptyfd, int *ttyfd, char *namebuf, int namebuflen)
162 } 162 }
163 return 1; 163 return 1;
164#else /* HAVE_DEV_PTS_AND_PTC */ 164#else /* HAVE_DEV_PTS_AND_PTC */
165#ifdef _CRAY
166 char buf[64];
167 int i;
168 int highpty;
169
170#ifdef _SC_CRAY_NPTY
171 highpty = sysconf(_SC_CRAY_NPTY);
172 if (highpty == -1)
173 highpty = 128;
174#else
175 highpty = 128;
176#endif
177
178 for (i = 0; i < highpty; i++) {
179 snprintf(buf, sizeof(buf), "/dev/pty/%03d", i);
180 *ptyfd = open(buf, O_RDWR|O_NOCTTY);
181 if (*ptyfd < 0) continue;
182 snprintf(namebuf, namebuflen, "/dev/ttyp%03d", i);
183 /* Open the slave side. */
184 *ttyfd = open(namebuf, O_RDWR|O_NOCTTY);
185 if (*ttyfd < 0) {
186 error("%.100s: %.100s", namebuf, strerror(errno));
187 close(*ptyfd);
188 }
189 return 1;
190 }
191 return 0;
192#else
165 /* BSD-style pty code. */ 193 /* BSD-style pty code. */
166 char buf[64]; 194 char buf[64];
167 int i; 195 int i;
@@ -196,6 +224,7 @@ pty_allocate(int *ptyfd, int *ttyfd, char *namebuf, int namebuflen)
196 return 1; 224 return 1;
197 } 225 }
198 return 0; 226 return 0;
227#endif /* CRAY */
199#endif /* HAVE_DEV_PTS_AND_PTC */ 228#endif /* HAVE_DEV_PTS_AND_PTC */
200#endif /* HAVE_DEV_PTMX */ 229#endif /* HAVE_DEV_PTMX */
201#endif /* HAVE__GETPTY */ 230#endif /* HAVE__GETPTY */
@@ -218,6 +247,35 @@ pty_release(const char *ttyname)
218void 247void
219pty_make_controlling_tty(int *ttyfd, const char *ttyname) 248pty_make_controlling_tty(int *ttyfd, const char *ttyname)
220{ 249{
250#ifdef _CRAY
251 int fd;
252
253 if (setsid() < 0)
254 error("setsid: %.100s", strerror(errno));
255
256 fd = open(ttyname, O_RDWR|O_NOCTTY);
257 if (fd >= 0) {
258 signal(SIGHUP, SIG_IGN);
259 ioctl(fd, TCVHUP, (char *)0);
260 signal(SIGHUP, SIG_DFL);
261 setpgid(0,0);
262 close(fd);
263 } else {
264 error("Failed to disconnect from controlling tty.");
265 }
266
267
268 debug("Setting controlling tty using TCSETCTTY.\n");
269 ioctl(*ttyfd, TCSETCTTY, NULL);
270
271 fd = open("/dev/tty", O_RDWR);
272
273 if (fd < 0)
274 error("%.100s: %.100s", ttyname, strerror(errno));
275
276 close(*ttyfd);
277 *ttyfd = fd;
278#else
221 int fd; 279 int fd;
222#ifdef USE_VHANGUP 280#ifdef USE_VHANGUP
223 void *old; 281 void *old;
@@ -277,6 +335,7 @@ pty_make_controlling_tty(int *ttyfd, const char *ttyname)
277 else { 335 else {
278 close(fd); 336 close(fd);
279 } 337 }
338#endif
280} 339}
281 340
282/* Changes the window size associated with the pty. */ 341/* Changes the window size associated with the pty. */