The pty module was doing too much - replacing the header and checking for functions. In the future, when we provide a working forkpty for Solaris and HP-UX, and a stub for mingw, then the separation will be even more useful.
* modules/pty (Makefile.am): Substitute new witnesses. (Libraries): Move library detection... * modules/forkpty: ...into new module. * modules/openpty: Another new module. * modules/pty-tests: Rename and split... * modules/forkpty-tests: ...to this... * modules/openpty-tests: ...and this. * tests/test-pty.c: Rename and split... * tests/test-forkpty.c: ...to this... * tests/test-openpty.c: ...and this. * m4/pty_h.m4 (gl_PTY_H_DEFAULTS): Add new witnesses. (gl_PTY): Split library searching... * m4/pty.m4 (gl_PTY_LIB): ...into new file. (gl_FORKPTY, gl_OPENPTY): New macros. * lib/pty.in.h (forkpty, openpty): Honor new witnesses. * NEWS: Mention the split. * MODULES.html.sh (Misc): Document the modules. * doc/glibc-functions/forkpty.texi (forkpty): Likewise. * doc/glibc-functions/openpty.texi (openpty): Likewise. Signed-off-by: Eric Blake <ebl...@redhat.com> --- ChangeLog | 23 +++++++++++++++++++++++ MODULES.html.sh | 3 +++ NEWS | 4 ++++ doc/glibc-functions/forkpty.texi | 2 +- doc/glibc-functions/openpty.texi | 2 +- lib/pty.in.h | 8 ++++---- m4/pty.m4 | 31 +++++++++++++++++++++++++++++++ m4/pty_h.m4 | 18 +++++------------- modules/forkpty | 26 ++++++++++++++++++++++++++ modules/forkpty-tests | 8 ++++++++ modules/openpty | 26 ++++++++++++++++++++++++++ modules/openpty-tests | 8 ++++++++ modules/pty | 2 ++ modules/pty-tests | 8 -------- tests/{test-pty.c => test-forkpty.c} | 12 +----------- tests/{test-pty.c => test-openpty.c} | 19 +------------------ 16 files changed, 144 insertions(+), 56 deletions(-) create mode 100644 m4/pty.m4 create mode 100644 modules/forkpty create mode 100644 modules/forkpty-tests create mode 100644 modules/openpty create mode 100644 modules/openpty-tests delete mode 100644 modules/pty-tests copy tests/{test-pty.c => test-forkpty.c} (79%) rename tests/{test-pty.c => test-openpty.c} (75%) diff --git a/ChangeLog b/ChangeLog index 73d2cd5..b5d0d63 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,28 @@ 2010-03-18 Eric Blake <ebl...@redhat.com> + forkpty, openpty: split functions into new modules + * modules/pty (Makefile.am): Substitute new witnesses. + (Libraries): Move library detection... + * modules/forkpty: ...into new module. + * modules/openpty: Another new module. + * modules/pty-tests: Rename and split... + * modules/forkpty-tests: ...to this... + * modules/openpty-tests: ...and this. + * tests/test-pty.c: Rename and split... + * tests/test-forkpty.c: ...to this... + * tests/test-openpty.c: ...and this. + * m4/pty_h.m4 (gl_PTY_H_DEFAULTS): Add new witnesses. + (gl_PTY): Split library searching... + * m4/pty.m4 (gl_PTY_LIB): ...into new file. + (gl_FORKPTY, gl_OPENPTY): New macros. + * lib/pty.in.h (forkpty, openpty): Honor new witnesses. + * NEWS: Mention the split. + * MODULES.html.sh (Misc): Document the modules. + * doc/glibc-functions/forkpty.texi (forkpty): Likewise. + * doc/glibc-functions/openpty.texi (openpty): Likewise. + +2010-03-18 Eric Blake <ebl...@redhat.com> + pty: improve replacement header * lib/pty.in.h: New file. * modules/pty (Files): Ship it. diff --git a/MODULES.html.sh b/MODULES.html.sh index 080c60a..b0fbe39 100755 --- a/MODULES.html.sh +++ b/MODULES.html.sh @@ -3143,6 +3143,7 @@ func_all_modules () func_module exitfail func_module error func_module extensions + func_module forkpty func_module getdomainname func_module xgetdomainname func_module getloadavg @@ -3150,9 +3151,11 @@ func_all_modules () func_module getusershell func_module lib-symbol-visibility func_module nproc + func_module openpty func_module physmem func_module posixver func_module progname + func_module pty func_module quotearg func_module quote func_module readutmp diff --git a/NEWS b/NEWS index ad639dd..0074492 100644 --- a/NEWS +++ b/NEWS @@ -6,6 +6,10 @@ User visible incompatible changes Date Modules Changes +2010-03-18 pty This module now only declares the pty.h header. + Use the new modules 'forkpty' or 'openpty' to + get the functions that were previously provided. + 2010-03-05 exit This module is deprecated, use 'stdlib' directly instead. It will be removed 2011-01-01. diff --git a/doc/glibc-functions/forkpty.texi b/doc/glibc-functions/forkpty.texi index 7701a38..8a86511 100644 --- a/doc/glibc-functions/forkpty.texi +++ b/doc/glibc-functions/forkpty.texi @@ -2,7 +2,7 @@ forkpty @subsection @code{forkpty} @findex forkpty -Gnulib module: pty +Gnulib module: forkpty Portability problems fixed by Gnulib: @itemize diff --git a/doc/glibc-functions/openpty.texi b/doc/glibc-functions/openpty.texi index 83975a9..7eb528e 100644 --- a/doc/glibc-functions/openpty.texi +++ b/doc/glibc-functions/openpty.texi @@ -2,7 +2,7 @@ openpty @subsection @code{openpty} @findex openpty -Gnulib module: pty +Gnulib module: openpty Portability problems fixed by Gnulib: @itemize diff --git a/lib/pty.in.h b/lib/pty.in.h index 8d80f8a..1b7bf82 100644 --- a/lib/pty.in.h +++ b/lib/pty.in.h @@ -44,21 +44,21 @@ /* Declare overridden functions. */ -#if 1 /* FIXME - split forkpty into separate module */ +#if @GNULIB_FORKPTY@ #elif defined GNULIB_POSIXCHECK # undef forkpty # if HAVE_RAW_DECL_FORKPTY _GL_WARN_ON_USE (forkpty, "forkpty is not declared consistently - " - "use gnulib module pty for portability"); + "use gnulib module forkpty for portability"); # endif #endif -#if 1 /* FIXME - split openpty into separate module */ +#if @GNULIB_OPENPTY@ #elif defined GNULIB_POSIXCHECK # undef openpty # if HAVE_RAW_DECL_OPENPTY _GL_WARN_ON_USE (openpty, "openpty is not declared consistently - " - "use gnulib module pty for portability"); + "use gnulib module openpty for portability"); # endif #endif diff --git a/m4/pty.m4 b/m4/pty.m4 new file mode 100644 index 0000000..f2a5664 --- /dev/null +++ b/m4/pty.m4 @@ -0,0 +1,31 @@ +# pty.m4 serial 1 +dnl Copyright (C) 2010 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_LIB +# ---------- +# Define automake variable PTY_LIB to the library needed (if any). +AC_DEFUN([gl_PTY_LIB], +[ + # Check for the library required for forkpty. + PTY_LIB= + 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_LIB]) +]) + +AC_DEFUN([gl_FORKPTY], +[ + AC_REQUIRE([gl_PTY_LIB]) +]) + +AC_DEFUN([gl_OPENPTY], +[ + AC_REQUIRE([gl_PTY_LIB]) +]) diff --git a/m4/pty_h.m4 b/m4/pty_h.m4 index 3b6d910..05ac357 100644 --- a/m4/pty_h.m4 +++ b/m4/pty_h.m4 @@ -1,4 +1,4 @@ -# pty_h.m4 serial 2 +# pty_h.m4 serial 3 dnl Copyright (C) 2009, 2010 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -7,13 +7,11 @@ 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_ONCE([gl_PTY], [ AC_REQUIRE([gl_PTY_H_DEFAULTS]) - PTY_LIB='' - # First make sure that pty.h provides forkpty, or setup the replacement. + # 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 HAVE_PTY_H=0 @@ -24,6 +22,7 @@ AC_DEFUN_ONCE([gl_PTY], if test $ac_cv_header_libutil_h = yes; then HAVE_LIBUTIL_H=1 fi + dnl FIXME - move this into forkpty module, when replacement is provided AC_CHECK_DECLS([forkpty],,, [[ #if HAVE_UTIL_H # include <util.h> @@ -42,15 +41,6 @@ AC_DEFUN_ONCE([gl_PTY], dnl <pty.h> is always overridden, because of GNULIB_POSIXCHECK. gl_CHECK_NEXT_HEADERS([pty.h]) - # 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_LIB]) - dnl Check for declarations of anything we want to poison if the dnl corresponding gnulib module is not in use. gl_WARN_ON_USE_PREPARE([[ @@ -75,6 +65,8 @@ AC_DEFUN([gl_PTY_MODULE_INDICATOR], AC_DEFUN([gl_PTY_H_DEFAULTS], [ + GNULIB_FORKPTY=0; AC_SUBST([GNULIB_FORKPTY]) + GNULIB_OPENPTY=0; AC_SUBST([GNULIB_OPENPTY]) dnl Assume proper GNU behavior unless another module says otherwise. HAVE_UTIL_H=0; AC_SUBST([HAVE_UTIL_H]) HAVE_LIBUTIL_H=0; AC_SUBST([HAVE_LIBUTIL_H]) diff --git a/modules/forkpty b/modules/forkpty new file mode 100644 index 0000000..5bfe0a5 --- /dev/null +++ b/modules/forkpty @@ -0,0 +1,26 @@ +Description: +Provide the forkpty() function. + +Files: +m4/pty.m4 + +Depends-on: +pty + +configure.ac: +gl_FORKPTY +gl_PTY_MODULE_INDICATOR([forkpty]) + +Makefile.am: + +Include: +<pty.h> + +Link: +$(PTY_LIB) + +License: +LGPL + +Maintainer: +Simon Josefsson diff --git a/modules/forkpty-tests b/modules/forkpty-tests new file mode 100644 index 0000000..744d684 --- /dev/null +++ b/modules/forkpty-tests @@ -0,0 +1,8 @@ +Files: +tests/signature.h +tests/test-forkpty.c + +Makefile.am: +TESTS += test-forkpty +check_PROGRAMS += test-forkpty +test_forkpty_LDADD = $(LDADD) $(PTY_LIB) diff --git a/modules/openpty b/modules/openpty new file mode 100644 index 0000000..68e00db --- /dev/null +++ b/modules/openpty @@ -0,0 +1,26 @@ +Description: +Provide the openpty() function. + +Files: +m4/pty.m4 + +Depends-on: +pty + +configure.ac: +gl_OPENPTY +gl_PTY_MODULE_INDICATOR([openpty]) + +Makefile.am: + +Include: +<pty.h> + +Link: +$(PTY_LIB) + +License: +LGPL + +Maintainer: +Simon Josefsson diff --git a/modules/openpty-tests b/modules/openpty-tests new file mode 100644 index 0000000..8b730e6 --- /dev/null +++ b/modules/openpty-tests @@ -0,0 +1,8 @@ +Files: +tests/signature.h +tests/test-openpty.c + +Makefile.am: +TESTS += test-openpty +check_PROGRAMS += test-openpty +test_openpty_LDADD = $(LDADD) $(PTY_LIB) diff --git a/modules/pty b/modules/pty index ef064be..8ea7ed3 100644 --- a/modules/pty +++ b/modules/pty @@ -25,6 +25,8 @@ pty.h: pty.in.h $(CXXDEFS_H) $(WARN_ON_USE_H) -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ -e 's|@''NEXT_PTY_H''@|$(NEXT_PTY_H)|g' \ + -e 's|@''GNULIB_FORKPTY''@|$(GNULIB_FORKPTY)|g' \ + -e 's|@''GNULIB_OPENPTY''@|$(GNULIB_OPENPTY)|g' \ -e 's|@''HAVE_UTIL_H''@|$(HAVE_UTIL_H)|g' \ -e 's|@''HAVE_LIBUTIL_H''@|$(HAVE_LIBUTIL_H)|g' \ -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ diff --git a/modules/pty-tests b/modules/pty-tests deleted file mode 100644 index 870d518..0000000 --- a/modules/pty-tests +++ /dev/null @@ -1,8 +0,0 @@ -Files: -tests/signature.h -tests/test-pty.c - -Makefile.am: -TESTS += test-pty -check_PROGRAMS += test-pty -test_pty_LDADD = $(LDADD) $(PTY_LIB) diff --git a/tests/test-pty.c b/tests/test-forkpty.c similarity index 79% copy from tests/test-pty.c copy to tests/test-forkpty.c index 72e126b..d87a107 100644 --- a/tests/test-pty.c +++ b/tests/test-forkpty.c @@ -1,4 +1,4 @@ -/* Test of pty.h and openpty/forkpty functions. +/* Test of pty.h and forkpty function. Copyright (C) 2009, 2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify @@ -23,8 +23,6 @@ #include "signature.h" SIGNATURE_CHECK (forkpty, int, (int *, char *, struct termios *, struct winsize *)); -SIGNATURE_CHECK (openpty, int, (int *, int *, char *, struct termios *, - struct winsize *)); #include <stdio.h> @@ -33,14 +31,6 @@ 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) diff --git a/tests/test-pty.c b/tests/test-openpty.c similarity index 75% rename from tests/test-pty.c rename to tests/test-openpty.c index 72e126b..255aeb0 100644 --- a/tests/test-pty.c +++ b/tests/test-openpty.c @@ -1,4 +1,4 @@ -/* Test of pty.h and openpty/forkpty functions. +/* Test of pty.h and openpty function. Copyright (C) 2009, 2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify @@ -21,8 +21,6 @@ #include <pty.h> #include "signature.h" -SIGNATURE_CHECK (forkpty, int, (int *, char *, struct termios *, - struct winsize *)); SIGNATURE_CHECK (openpty, int, (int *, int *, char *, struct termios *, struct winsize *)); @@ -42,20 +40,5 @@ main () 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; } -- 1.6.6.1