summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Jennings <mej@kainx.org>2009-10-25 20:30:06 +0000
committerMichael Jennings <mej@kainx.org>2009-10-25 20:30:06 +0000
commit42a135456a75ba914291984b0c83942ac6664f75 (patch)
treeadba3ae09d57eb83d398e3553cc66a4754481041
parentc6ff25f5f1391f8c7cdf0c487c284e91fdd747e9 (diff)
downloadeterm-42a135456a75ba914291984b0c83942ac6664f75.tar.gz
Sun Oct 25 12:36:01 2009 Michael Jennings (mej)
Patch for FreeBSD UNIX98 pty support from Ed Schouten <ed@80386.nl>. ---------------------------------------------------------------------- SVN revision: 43281
-rw-r--r--ChangeLog7
-rw-r--r--configure.ac7
-rw-r--r--src/command.c16
-rw-r--r--src/utmp.c19
4 files changed, 33 insertions, 16 deletions
diff --git a/ChangeLog b/ChangeLog
index 896b45a..3dc8126 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -5606,5 +5606,10 @@ Fix some bad replacements.
Sun Oct 25 12:29:32 2009 Michael Jennings (mej)
Re-enable SIGPIPE after fork() for child processes who might not
-re-enable it on their own.
+re-enable it on their own. Pointed out by Sylvain Martin
+<sylvain.martin@ulg.ac.be>.
+----------------------------------------------------------------------
+Sun Oct 25 12:36:01 2009 Michael Jennings (mej)
+
+Patch for FreeBSD UNIX98 pty support from Ed Schouten <ed@80386.nl>.
----------------------------------------------------------------------
diff --git a/configure.ac b/configure.ac
index 03d0a4c..1e4502d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -258,6 +258,9 @@ AC_ARG_WITH(debugging, [ --with-debugging[=num] enable debugging output, num i
AC_DEFINE_UNQUOTED(DEBUG, 4, [Debugging level to compile in.])
])
+AC_CHECK_FUNC(posix_openpt,
+ HAVE_POSIX_OPENPT=yes
+ )
AC_CHECK_FUNC(ptsname,
HAVE_PTSNAME=yes
)
@@ -270,6 +273,10 @@ AC_CHECK_FUNC(unlockpt,
dnl# Check for the appropriate pty mechanism
AC_MSG_CHECKING(for pty mechanism)
PTY_MECH=""
+if test ! -z "$HAVE_POSIX_OPENPT" -a ! -z "$HAVE_PTSNAME" -a ! -z "$HAVE_GRANTPT" -a ! -z "$HAVE_UNLOCKPT"; then
+ AC_DEFINE(HAVE_POSIX_OPENPT, , [Define for posix_openpt() support.])
+ PTY_MECH="POSIX $PTY_MECH"
+fi
if test -c /dev/ptc ; then
AC_DEFINE(HAVE_DEV_PTC, , [Define for /dev/ptc support.])
PTY_MECH="AIX $PTY_MECH"
diff --git a/src/command.c b/src/command.c
index 05dca7c..65fc09f 100644
--- a/src/command.c
+++ b/src/command.c
@@ -1386,17 +1386,21 @@ sco_get_pty(void)
}
#endif
-#ifdef HAVE_DEV_PTMX
-inline int svr_get_pty(void);
+#if defined(HAVE_POSIX_OPENPT) || defined(HAVE_DEV_PTMX)
+inline int posix_get_pty(void);
inline int
-svr_get_pty(void)
+posix_get_pty(void)
{
int fd = -1;
/* open the STREAMS, clone device /dev/ptmx (master pty) */
+#if defined(HAVE_POSIX_OPENPT)
+ if ((fd = posix_openpt(O_RDWR|O_NOCTTY)) < 0) {
+#else
if ((fd = open("/dev/ptmx", O_RDWR)) < 0) {
+#endif
return (-1);
} else {
if (grantpt(fd) != 0) {
@@ -1455,12 +1459,12 @@ get_pty(void)
int fd = -1;
-#if defined(__sgi)
+#if defined(HAVE_POSIX_OPENPT) || defined(HAVE_DEV_PTMX)
+ fd = posix_get_pty();
+#elif defined(__sgi)
fd = sgi_get_pty();
#elif defined(HAVE_DEV_PTC)
fd = aix_get_pty();
-#elif defined(HAVE_DEV_PTMX)
- fd = svr_get_pty();
#elif defined(HAVE_SCO_PTYS)
fd = sco_get_pty();
#endif
diff --git a/src/utmp.c b/src/utmp.c
index 8136eb0..f946514 100644
--- a/src/utmp.c
+++ b/src/utmp.c
@@ -38,9 +38,9 @@ static const char cvs_ident[] = "$Id$";
# endif
/* don't go off end of ut_id & remember if an entry has been made */
-# if defined(USE_SYSV_UTMP) || defined(NEW_BSD_UTMP) || defined(__OpenBSD__)
+# if defined(USE_SYSV_UTMP) || defined(__OpenBSD__)
static char ut_id[5]; /* remember if entry to utmp made */
-# else
+# elif !defined(NEW_BSD_UTMP)
static int utmp_pos; /* BSD position of utmp-stamp */
# endif
@@ -340,13 +340,6 @@ add_utmp_entry(const char *pty, const char *hostname, int fd)
if (!strncmp(pty, "/dev/", 5))
pty += 5; /* skip /dev/ prefix */
- if (!strncmp(pty, "pty", 3) || !strncmp(pty, "tty", 3))
- strncpy(ut_id, (pty + 3), sizeof(ut_id)); /* bsd naming */
- else {
- libast_print_error("can't parse tty name \"%s\"\n", pty);
- ut_id[0] = '\0'; /* entry not made */
- return;
- }
# ifdef NEW_BSD_UTMP
strncpy(ut_line, pty, 31);
@@ -358,6 +351,14 @@ add_utmp_entry(const char *pty, const char *hostname, int fd)
b_login(&utmp);
# else /* NEW_BSD_UTMP */
+ if (!strncmp(pty, "pty", 3) || !strncmp(pty, "tty", 3))
+ strncpy(ut_id, (pty + 3), sizeof(ut_id)); /* bsd naming */
+ else {
+ libast_print_error("can't parse tty name \"%s\"\n", pty);
+ ut_id[0] = '\0'; /* entry not made */
+ return;
+ }
+
strncpy(utmp.ut_line, ut_id, sizeof(utmp.ut_line));
strncpy(utmp.ut_name, pwent->pw_name, sizeof(utmp.ut_name));
strncpy(utmp.ut_host, hostname, sizeof(utmp.ut_host));