0a9d40c452
- no need for groff - sync patches ok gsoares@
72 lines
2.1 KiB
Plaintext
72 lines
2.1 KiB
Plaintext
$OpenBSD: patch-Tty_xs,v 1.2 2011/10/28 22:38:15 okan Exp $
|
|
--- Tty.xs.orig Mon Oct 11 14:07:57 2010
|
|
+++ Tty.xs Tue Oct 11 23:43:40 2011
|
|
@@ -233,6 +233,7 @@ make_safe_fd(int * fd)
|
|
}
|
|
}
|
|
|
|
+#if !defined(HAVE_OPENPTY)
|
|
/*
|
|
* After having acquired a master pty, try to find out the slave name,
|
|
* initialize and open the slave.
|
|
@@ -395,6 +396,7 @@ open_slave(int *ptyfd, int *ttyfd, char *namebuf, int
|
|
|
|
return 1;
|
|
}
|
|
+#endif
|
|
|
|
/*
|
|
* Allocates and opens a pty. Returns 0 if no pty could be allocated, or
|
|
@@ -450,7 +452,7 @@ allocate_pty(int *ptyfd, int *ttyfd, char *namebuf, in
|
|
}
|
|
#endif
|
|
|
|
-#if defined(HAVE_PTSNAME) || defined(HAVE_PTSNAME_R)
|
|
+#if defined(HAVE_PTSNAME) || defined(HAVE_PTSNAME_R) || defined(HAVE_OPENPTY)
|
|
/* we don't need to try these if we don't have a way to get the pty names */
|
|
|
|
#if defined(HAVE_POSIX_OPENPT)
|
|
@@ -479,29 +481,21 @@ allocate_pty(int *ptyfd, int *ttyfd, char *namebuf, in
|
|
#endif /* defined(HAVE_GETPT) */
|
|
|
|
#if defined(HAVE_OPENPTY)
|
|
- /* openpty(3) exists in a variety of OS'es, but due to it's
|
|
- * broken interface (no maxlen to slavename) we'll only use it
|
|
- * to create the tty/pty pair and rely on ptsname to get the
|
|
- * name. */
|
|
- {
|
|
- mysig_t old_signal;
|
|
- int ret;
|
|
-
|
|
+ /* openpty(3) is documented to require 16 bytes for the
|
|
+ * slave name. We always allocate 64 so it is safe...
|
|
+ */
|
|
#if PTY_DEBUG
|
|
- if (print_debug)
|
|
- fprintf(stderr, "trying openpty()...\n");
|
|
+ if (print_debug)
|
|
+ fprintf(stderr, "trying openpty()...\n");
|
|
#endif
|
|
- old_signal = mysignal(SIGCHLD, SIG_DFL);
|
|
- ret = openpty(ptyfd, ttyfd, NULL, NULL, NULL);
|
|
- mysignal(SIGCHLD, old_signal);
|
|
- if (ret >= 0 && *ptyfd >= 0) {
|
|
- if (open_slave(ptyfd, ttyfd, namebuf, namebuflen))
|
|
- break;
|
|
- }
|
|
- *ptyfd = -1;
|
|
- *ttyfd = -1;
|
|
- if (PL_dowarn)
|
|
- warn("pty_allocate(nonfatal): openpty(): %.100s", strerror(errno));
|
|
+ if (openpty(ptyfd, ttyfd, namebuf, NULL, NULL) == 0) {
|
|
+ make_safe_fd(ptyfd);
|
|
+ make_safe_fd(ttyfd);
|
|
+ return 1;
|
|
+ } else {
|
|
+ if (PL_dowarn)
|
|
+ warn("pty_allocate: openpty(): %.100s", strerror(errno));
|
|
+ return 0;
|
|
}
|
|
#endif /* defined(HAVE_OPENPTY) */
|
|
|