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)
downloadopenssh-git-f744b512f310db2c7e317ad55be011e21cd13ac3.tar.gz
- (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 84572c90..31abd696 100644
--- a/sshpty.c
+++ b/sshpty.c
@@ -168,27 +168,28 @@ pty_allocate(int *ptyfd, int *ttyfd, char *namebuf, int namebuflen)
int highpty;
#ifdef _SC_CRAY_NPTY
- highpty = sysconf(_SC_CRAY_NPTY);
- if (highpty == -1)
- highpty = 128;
+ highpty = sysconf(_SC_CRAY_NPTY);
+ if (highpty == -1)
+ highpty = 128;
#else
- highpty = 128;
+ 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) {
+ 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;
+ close(*ptyfd);
+ }
+ return 1;
+ }
+ return 0;
#else
/* BSD-style pty code. */
char buf[64];
@@ -250,29 +251,25 @@ pty_make_controlling_tty(int *ttyfd, const char *ttyname)
#ifdef _CRAY
int fd;
- if (setsid() < 0)
- error("setsid: %.100s", strerror(errno));
+ 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);
+ fd = open(ttyname, O_RDWR|O_NOCTTY);
+ if (fd != -1) {
+ signal(SIGHUP, SIG_IGN);
+ ioctl(fd, TCVHUP, (char *)NULL);
+ signal(SIGHUP, SIG_DFL);
+ setpgid(0, 0);
+ close(fd);
} else {
- error("Failed to disconnect from controlling tty.");
+ 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));
+ debug("Setting controlling tty using TCSETCTTY.");
+ ioctl(*ttyfd, TCSETCTTY, NULL);
+ fd = open("/dev/tty", O_RDWR);
+ if (fd < 0)
+ error("%.100s: %.100s", ttyname, strerror(errno));
close(*ttyfd);
*ttyfd = fd;
#else