summaryrefslogtreecommitdiff
path: root/pty.c
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>1999-11-25 11:54:57 +1100
committerDamien Miller <djm@mindrot.org>1999-11-25 11:54:57 +1100
commit5428f646ad32da88ddd04a8c287d595524674fbf (patch)
treecc1f1e5d7852e1f44d41077f776abf7dab7ac06d /pty.c
parent9072e1889648988da38b7b81bce95291c1dc3a23 (diff)
- More reformatting merged from OpenBSD CVS
- Merged OpenBSD CVS changes: - [channels.c] report from mrwizard@psu.edu via djm@ibs.com.au - [channels.c] set SO_REUSEADDR and SO_LINGER for forwarded ports. chip@valinux.com via damien@ibs.com.au - [nchan.c] it's not an error() if shutdown_write failes in nchan. - [readconf.c] remove dead #ifdef-0-code - [readconf.c servconf.c] strcasecmp instead of tolower - [scp.c] progress meter overflow fix from damien@ibs.com.au - [ssh-add.1 ssh-add.c] SSH_ASKPASS support - [ssh.1 ssh.c] postpone fork_after_authentication until command execution, request/patch from jahakala@cc.jyu.fi via damien@ibs.com.au plus: use daemon() for backgrounding
Diffstat (limited to 'pty.c')
-rw-r--r--pty.c44
1 files changed, 26 insertions, 18 deletions
diff --git a/pty.c b/pty.c
index 34ed48d6..e4684213 100644
--- a/pty.c
+++ b/pty.c
@@ -14,7 +14,7 @@
*/
#include "includes.h"
-RCSID("$Id: pty.c,v 1.4 1999/11/24 13:26:22 damien Exp $");
+RCSID("$Id: pty.c,v 1.5 1999/11/25 00:54:59 damien Exp $");
#include "pty.h"
#include "ssh.h"
@@ -32,10 +32,12 @@ RCSID("$Id: pty.c,v 1.4 1999/11/24 13:26:22 damien Exp $");
#define O_NOCTTY 0
#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
- 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). */
+/*
+ * 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
+ * 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
pty_allocate(int *ptyfd, int *ttyfd, char *namebuf)
@@ -52,8 +54,10 @@ pty_allocate(int *ptyfd, int *ttyfd, char *namebuf)
return 1;
#else /* HAVE_OPENPTY */
#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;
slave = _getpty(ptyfd, O_RDWR, 0622, 0);
@@ -72,8 +76,10 @@ pty_allocate(int *ptyfd, int *ttyfd, char *namebuf)
return 1;
#else /* HAVE__GETPTY */
#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;
char *pts;
@@ -103,8 +109,7 @@ pty_allocate(int *ptyfd, int *ttyfd, char *namebuf)
close(*ptyfd);
return 0;
}
- /* Push the appropriate streams modules, as described in Solaris
- pts(7). */
+ /* Push the appropriate streams modules, as described in Solaris pts(7). */
if (ioctl(*ttyfd, I_PUSH, "ptem") < 0)
error("ioctl I_PUSH ptem: %.100s", strerror(errno));
if (ioctl(*ttyfd, I_PUSH, "ldterm") < 0)
@@ -138,8 +143,7 @@ pty_allocate(int *ptyfd, int *ttyfd, char *namebuf)
/* BSD-style pty code. */
char buf[64];
int i;
- const char *ptymajors =
- "pqrstuvwxyzabcdefghijklmnoABCDEFGHIJKLMNOPQRSTUVWXYZ";
+ const char *ptymajors = "pqrstuvwxyzabcdefghijklmnoABCDEFGHIJKLMNOPQRSTUVWXYZ";
const char *ptyminors = "0123456789abcdef";
int num_minors = strlen(ptyminors);
int num_ptys = strlen(ptymajors) * num_minors;
@@ -198,8 +202,10 @@ pty_make_controlling_tty(int *ttyfd, const char *ttyname)
if (setsid() < 0)
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);
if (fd >= 0) {
error("Failed to disconnect from controlling tty.");
@@ -208,9 +214,11 @@ pty_make_controlling_tty(int *ttyfd, const char *ttyname)
/* Make it our controlling tty. */
#ifdef 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
- absolutely no documentation. */
+ /*
+ * We ignore errors from this, because HPSUX defines TIOCSCTTY, but
+ * returns EINVAL with these arguments, and there is absolutely no
+ * documentation.
+ */
ioctl(*ttyfd, TIOCSCTTY, NULL);
#endif /* TIOCSCTTY */
fd = open(ttyname, O_RDWR);