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
This commit is contained in:
Michael Jennings 2009-10-25 20:30:06 +00:00
parent c6ff25f5f1
commit 42a135456a
4 changed files with 33 additions and 16 deletions

View File

@ -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>.
----------------------------------------------------------------------

View File

@ -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"

View File

@ -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

View File

@ -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));