+2009-12-07 Simon Josefsson <simon@josefsson.org>
+
+ * modules/pty: New file.
+ * modules/pty-tests: New file.
+ * m4/pty.m4: New file.
+ * tests/test-pty.c: New file.
+ * doc/glibc-headers/pty.texi: Modified.
+ * doc/glibc-functions/forkpty.texi: Modified.
+ * doc/glibc-functions/openpty.texi: Modified.
+
2009-12-09 Bruno Haible <bruno@clisp.org>
Avoid syntax error in C++ mode.
@subsection @code{forkpty}
@findex forkpty
-Gnulib module: ---
+Gnulib module: pty
Portability problems fixed by Gnulib:
@itemize
-@end itemize
-
-Portability problems not fixed by Gnulib:
-@itemize
@item
One some systems (at least including Cygwin, Interix, OSF/1 4 and 5,
and Mac OS X) linking with @code{-lutil} is not required.
and glibc. It is declared in util.h on Mac OS X, OpenBSD and NetBSD.
It is declared in libutil.h on FreeBSD.
@end itemize
+
+Portability problems not fixed by Gnulib:
+@itemize
+On some systems (at least including Solaris and HP-UX) the function is
+missing.
+@end itemize
@subsection @code{openpty}
@findex openpty
-Gnulib module: ---
+Gnulib module: pty
Portability problems fixed by Gnulib:
@itemize
-@end itemize
-
-Portability problems not fixed by Gnulib:
-@itemize
@item
One some systems (at least including Cygwin, Interix, OSF/1 4 and 5,
and Mac OS X) linking with @code{-lutil} is not required.
and glibc. It is declared in util.h on Mac OS X, OpenBSD and NetBSD.
It is declared in libutil.h on FreeBSD.
@end itemize
+
+Portability problems not fixed by Gnulib:
+@itemize
+@item
+On some systems (at least including Solaris and HP-UX) the function is
+missing.
+@end itemize
@uref{http://www.kernel.org/doc/man-pages/online/pages/man3/openpty.3.html,,man openpty}.
@end itemize
-Gnulib module: ---
+Gnulib module: pty
Portability problems fixed by Gnulib:
@itemize
+@item
+This header file is missing on some platforms that declare the
+@code{forkpty} and @code{openpty} functions in @code{util.h} or
+@code{libutil.h} instead: MacOS X 10.3, FreeBSD 6.0, NetBSD 3.0,
+OpenBSD 3.8.
@end itemize
Portability problems not fixed by Gnulib:
@itemize
@item
This header file is missing on some platforms:
-MacOS X 10.3, FreeBSD 6.0, NetBSD 3.0, OpenBSD 3.8, AIX 5.1, HP-UX 11, IRIX 6.5, Solaris 10, mingw, BeOS.
+AIX 5.1, HP-UX 11, IRIX 6.5, Solaris 10, mingw, BeOS.
@end itemize
--- /dev/null
+# pty.m4 serial 1
+dnl Copyright (C) 2009 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+# gl_PTY
+# ------
+# Make sure that pty.h provides forkpty, or sets up a replacement header.
+# Also define automake variable PTY_LIB to the library needed (if any).
+AC_DEFUN([gl_PTY],
+[
+ PTY_H=''
+ PTY_LIB=''
+ # First make sure that pty.h provides forkpty, or setup the replacement.
+ AC_CHECK_HEADERS_ONCE([pty.h])
+ if test $ac_cv_header_pty_h != yes; then
+ AC_CHECK_DECL([forkpty],,, [[#include <util.h>]])
+ if test $ac_cv_have_decl_forkpty = no; then
+ AC_CHECK_DECL([forkpty],,, [[#include <libutil.h>]])
+ if test $ac_cv_have_decl_forkpty = no; then
+ AC_MSG_WARN([[Cannot find forkpty, build will likely fail]])
+ else
+ PTY_H='pty.h'
+ PTY_HEADER='libutil.h'
+ fi
+ else
+ PTY_H='pty.h'
+ PTY_HEADER='util.h'
+ fi
+ fi
+ # Second check for the library required for forkpty.
+ save_LIBS="$LIBS"
+ AC_SEARCH_LIBS([forkpty], [util],
+ [if test "$ac_cv_search_forkpty" != "none required"; then
+ PTY_LIB="$ac_cv_search_forkpty"
+ fi])
+ LIBS="$save_LIBS"
+ AC_SUBST([PTY_H])
+ AC_SUBST([PTY_LIB])
+ AC_SUBST([PTY_HEADER])
+])
--- /dev/null
+Description:
+A <pty.h> for systems that lacks it.
+
+Files:
+m4/pty.m4
+
+configure.ac:
+gl_PTY
+
+Makefile.am:
+BUILT_SOURCES += $(PTY_H)
+
+# We need the following in order to create <pty.h> when the system
+# doesn't have one that works with the given compiler.
+pty.h:
+ $(AM_V_GEN)rm -f $@-t $@ && \
+ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
+ echo '#include <'$(PTY_HEADER)'>'; \
+ } > $@-t && \
+ mv -f $@-t $@
+MOSTLYCLEANFILES += pty.h pty.h-t
+
+Include:
+<pty.h>
+
+Link:
+$(PTY_LIB)
+
+License:
+LGPL
+
+Maintainer:
+Simon Josefsson
--- /dev/null
+Files:
+tests/test-pty.c
+
+Makefile.am:
+TESTS += test-pty
+check_PROGRAMS += test-pty
+test_pty_LDADD = $(PTY_LIB)
--- /dev/null
+/* Test of pty.h and openpty/forkpty functions.
+ Copyright (C) 2009 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+/* Written by Simon Josefsson <simon@josefsson.org>, 2009. */
+
+#include <config.h>
+
+#include <pty.h>
+
+#include <stdio.h>
+
+int
+main ()
+{
+ int res;
+ int amaster;
+ int aslave;
+
+ res = openpty (&amaster, &aslave, NULL, NULL, NULL);
+ if (res != 0)
+ {
+ printf ("openpty returned %d\n", res);
+ return 1;
+ }
+
+ res = forkpty (&amaster, NULL, NULL, NULL);
+ if (res == 0)
+ {
+ /* child process */
+ }
+ else if (res > 0)
+ {
+ /* parent */
+ }
+ else
+ {
+ printf ("forkpty returned %d\n", res);
+ return 1;
+ }
+
+ return 0;
+}