summaryrefslogtreecommitdiff
path: root/sshpty.c
diff options
context:
space:
mode:
authorKevin Steves <stevesk@pobox.com>2001-08-14 20:31:49 +0000
committerKevin Steves <stevesk@pobox.com>2001-08-14 20:31:49 +0000
commitf744b512f310db2c7e317ad55be011e21cd13ac3 (patch)
tree04f93497fd572bd10636df391ff8de6b2f0b61d4 /sshpty.c
parent56cb92968bc94322561e44959680a4dcf98bcc55 (diff)
- (stevesk) sshpty.c, cray.[ch]: whitespace, formatting and cleanup
for some #ifdef _CRAY code; ok wendyp@cray.com
Diffstat (limited to 'sshpty.c')
-rw-r--r--sshpty.c69
1 files changed, 33 insertions, 36 deletions
diff --git a/sshpty.c b/sshpty.c
index 84572c901..31abd696c 100644
--- a/sshpty.c
+++ b/sshpty.c
@@ -168,27 +168,28 @@ pty_allocate(int *ptyfd, int *ttyfd, char *namebuf, int namebuflen)
168 int highpty; 168 int highpty;
169 169
170#ifdef _SC_CRAY_NPTY 170#ifdef _SC_CRAY_NPTY
171 highpty = sysconf(_SC_CRAY_NPTY); 171 highpty = sysconf(_SC_CRAY_NPTY);
172 if (highpty == -1) 172 if (highpty == -1)
173 highpty = 128; 173 highpty = 128;
174#else 174#else
175 highpty = 128; 175 highpty = 128;
176#endif 176#endif
177 177
178 for (i = 0; i < highpty; i++) { 178 for (i = 0; i < highpty; i++) {
179 snprintf(buf, sizeof(buf), "/dev/pty/%03d", i); 179 snprintf(buf, sizeof(buf), "/dev/pty/%03d", i);
180 *ptyfd = open(buf, O_RDWR|O_NOCTTY); 180 *ptyfd = open(buf, O_RDWR|O_NOCTTY);
181 if (*ptyfd < 0) continue; 181 if (*ptyfd < 0)
182 snprintf(namebuf, namebuflen, "/dev/ttyp%03d", i); 182 continue;
183 /* Open the slave side. */ 183 snprintf(namebuf, namebuflen, "/dev/ttyp%03d", i);
184 *ttyfd = open(namebuf, O_RDWR|O_NOCTTY); 184 /* Open the slave side. */
185 if (*ttyfd < 0) { 185 *ttyfd = open(namebuf, O_RDWR|O_NOCTTY);
186 if (*ttyfd < 0) {
186 error("%.100s: %.100s", namebuf, strerror(errno)); 187 error("%.100s: %.100s", namebuf, strerror(errno));
187 close(*ptyfd); 188 close(*ptyfd);
188 } 189 }
189 return 1; 190 return 1;
190 } 191 }
191 return 0; 192 return 0;
192#else 193#else
193 /* BSD-style pty code. */ 194 /* BSD-style pty code. */
194 char buf[64]; 195 char buf[64];
@@ -250,29 +251,25 @@ pty_make_controlling_tty(int *ttyfd, const char *ttyname)
250#ifdef _CRAY 251#ifdef _CRAY
251 int fd; 252 int fd;
252 253
253 if (setsid() < 0) 254 if (setsid() < 0)
254 error("setsid: %.100s", strerror(errno)); 255 error("setsid: %.100s", strerror(errno));
255 256
256 fd = open(ttyname, O_RDWR|O_NOCTTY); 257 fd = open(ttyname, O_RDWR|O_NOCTTY);
257 if (fd >= 0) { 258 if (fd != -1) {
258 signal(SIGHUP, SIG_IGN); 259 signal(SIGHUP, SIG_IGN);
259 ioctl(fd, TCVHUP, (char *)0); 260 ioctl(fd, TCVHUP, (char *)NULL);
260 signal(SIGHUP, SIG_DFL); 261 signal(SIGHUP, SIG_DFL);
261 setpgid(0,0); 262 setpgid(0, 0);
262 close(fd); 263 close(fd);
263 } else { 264 } else {
264 error("Failed to disconnect from controlling tty."); 265 error("Failed to disconnect from controlling tty.");
265 } 266 }
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 267
268 debug("Setting controlling tty using TCSETCTTY.");
269 ioctl(*ttyfd, TCSETCTTY, NULL);
270 fd = open("/dev/tty", O_RDWR);
271 if (fd < 0)
272 error("%.100s: %.100s", ttyname, strerror(errno));
276 close(*ttyfd); 273 close(*ttyfd);
277 *ttyfd = fd; 274 *ttyfd = fd;
278#else 275#else