+2010-03-21 Bruno Haible <bruno@clisp.org>
+
+ New module 'unlockpt'.
+ * lib/unlockpt.c: New file, from glibc with modifications.
+ * m4/unlockpt.m4: New file.
+ * modules/unlockpt: New file.
+ * lib/stdlib.in.h (unlockpt): New declaration.
+ * m4/stdlib_h.m4 (gl_STDLIB_H): Check whether unlockpt is declared.
+ (gl_STDLIB_H_DEFAULTS): Initialize GNULIB_UNLOCKPT, HAVE_UNLOCKPT.
+ * modules/stdlib (Makefile.am): Substitute GNULIB_UNLOCKPT,
+ HAVE_UNLOCKPT.
+ * doc/posix-functions/unlockpt.texi: Mention the new module.
+ * tests/test-stdlib-c++.cc: Check GNULIB_NAMESPACE::unlockpt.
+ * config/srclist.txt: Add unlockpt.c (commented).
+
2010-03-21 Jim Meyering <meyering@redhat.com>
maint.mk: prohibit inclusion of "intprops.h" without use
#$LIBCSRC/sysdeps/posix/tempname.c lib gpl
#$LIBCSRC/sysdeps/unix/bsd/poll.c lib gpl
#$LIBCSRC/sysdeps/unix/bsd/ptsname.c lib gpl
+#$LIBCSRC/sysdeps/unix/bsd/unlockpt.c lib gpl
#$LIBCSRC/sysdeps/unix/dirfd.c lib gpl
#$LIBCSRC/sysdeps/unix/grantpt.c lib gpl
#$LIBCSRC/sysdeps/unix/rmdir.c lib gpl
POSIX specification: @url{http://www.opengroup.org/onlinepubs/9699919799/functions/unlockpt.html}
-Gnulib module: ---
+Gnulib module: unlockpt
Portability problems fixed by Gnulib:
@itemize
+@item
+This function is missing on some platforms:
+MacOS X 10.3, OpenBSD 3.8, mingw, BeOS.
@end itemize
Portability problems not fixed by Gnulib:
@itemize
-@item
-This function is missing on some platforms:
-MacOS X 10.3, OpenBSD 3.8, mingw, BeOS.
@end itemize
# endif
#endif
+#if @GNULIB_UNLOCKPT@
+/* Unlock the slave side of the pseudo-terminal whose master side is specified
+ by FD, so that it can be opened. */
+# if !@HAVE_UNLOCKPT@
+_GL_FUNCDECL_SYS (unlockpt, int, (int fd));
+# endif
+_GL_CXXALIAS_SYS (unlockpt, int, (int fd));
+_GL_CXXALIASWARN (unlockpt);
+#elif defined GNULIB_POSIXCHECK
+# undef unlockpt
+# if HAVE_RAW_DECL_UNLOCKPT
+_GL_WARN_ON_USE (ptsname, "unlockpt is not portable - "
+ "use gnulib module unlockpt for portability");
+# endif
+#endif
+
#if @GNULIB_UNSETENV@
/* Remove the variable NAME from the environment. */
# if @REPLACE_UNSETENV@
--- /dev/null
+/* Unlock the slave side of a pseudo-terminal from its master side.
+ Copyright (C) 1998, 2010 Free Software Foundation, Inc.
+ Contributed by Zack Weinberg <zack@rabi.phys.columbia.edu>, 1998.
+
+ 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/>. */
+
+#include <config.h>
+
+#include <stdlib.h>
+
+#include <unistd.h>
+
+int
+unlockpt (int fd)
+{
+ /* Platforms which have the TIOCSPTLCK ioctl (Linux) already have the
+ unlockpt function. */
+#if HAVE_REVOKE
+ /* MacOS X 10.3, OpenBSD 3.8 do not have the unlockpt function, but they
+ have revoke(). */
+ char *name = ptsname (fd);
+ if (name == NULL)
+ return -1;
+ return revoke (name);
+#else
+ /* Assume that the slave side of a pseudo-terminal is already unlocked
+ by default. */
+ return 0;
+#endif
+}
-# stdlib_h.m4 serial 25
+# stdlib_h.m4 serial 26
dnl Copyright (C) 2007-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,
#endif
]], [atoll canonicalize_file_name getloadavg getsubopt grantpt mkdtemp
mkostemp mkostemps mkstemp mkstemps ptsname random_r initstat_r srandom_r
- setstate_r realpath rpmatch setenv strtod strtoll strtoull unsetenv])
+ setstate_r realpath rpmatch setenv strtod strtoll strtoull unlockpt
+ unsetenv])
])
AC_DEFUN([gl_STDLIB_MODULE_INDICATOR],
GNULIB_STRTOD=0; AC_SUBST([GNULIB_STRTOD])
GNULIB_STRTOLL=0; AC_SUBST([GNULIB_STRTOLL])
GNULIB_STRTOULL=0; AC_SUBST([GNULIB_STRTOULL])
+ GNULIB_UNLOCKPT=0; AC_SUBST([GNULIB_UNLOCKPT])
GNULIB_UNSETENV=0; AC_SUBST([GNULIB_UNSETENV])
dnl Assume proper GNU behavior unless another module says otherwise.
HAVE_ATOLL=1; AC_SUBST([HAVE_ATOLL])
HAVE_STRTOULL=1; AC_SUBST([HAVE_STRTOULL])
HAVE_STRUCT_RANDOM_DATA=1; AC_SUBST([HAVE_STRUCT_RANDOM_DATA])
HAVE_SYS_LOADAVG_H=0; AC_SUBST([HAVE_SYS_LOADAVG_H])
+ HAVE_UNLOCKPT=1; AC_SUBST([HAVE_UNLOCKPT])
HAVE_UNSETENV=1; AC_SUBST([HAVE_UNSETENV])
REPLACE_CANONICALIZE_FILE_NAME=0; AC_SUBST([REPLACE_CANONICALIZE_FILE_NAME])
REPLACE_MKSTEMP=0; AC_SUBST([REPLACE_MKSTEMP])
--- /dev/null
+# unlockpt.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.
+
+AC_DEFUN([gl_FUNC_UNLOCKPT],
+[
+ AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
+
+ dnl Persuade glibc <stdlib.h> to declare unlockpt().
+ AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
+
+ AC_CHECK_FUNCS([unlockpt])
+ if test $ac_cv_func_unlockpt = no; then
+ HAVE_UNLOCKPT=0
+ AC_LIBOBJ([unlockpt])
+ gl_PREREQ_UNLOCKPT
+ fi
+])
+
+# Prerequisites of lib/unlockpt.c.
+AC_DEFUN([gl_PREREQ_UNLOCKPT], [
+ AC_CHECK_FUNCS([revoke])
+])
-e 's|@''GNULIB_STRTOD''@|$(GNULIB_STRTOD)|g' \
-e 's|@''GNULIB_STRTOLL''@|$(GNULIB_STRTOLL)|g' \
-e 's|@''GNULIB_STRTOULL''@|$(GNULIB_STRTOULL)|g' \
+ -e 's|@''GNULIB_UNLOCKPT''@|$(GNULIB_UNLOCKPT)|g' \
-e 's|@''GNULIB_UNSETENV''@|$(GNULIB_UNSETENV)|g' \
-e 's|@''HAVE_ATOLL''@|$(HAVE_ATOLL)|g' \
-e 's|@''HAVE_CALLOC_POSIX''@|$(HAVE_CALLOC_POSIX)|g' \
-e 's|@''HAVE_STRTOULL''@|$(HAVE_STRTOULL)|g' \
-e 's|@''HAVE_STRUCT_RANDOM_DATA''@|$(HAVE_STRUCT_RANDOM_DATA)|g' \
-e 's|@''HAVE_SYS_LOADAVG_H''@|$(HAVE_SYS_LOADAVG_H)|g' \
+ -e 's|@''HAVE_UNLOCKPT''@|$(HAVE_UNLOCKPT)|g' \
-e 's|@''HAVE_UNSETENV''@|$(HAVE_UNSETENV)|g' \
-e 's|@''REPLACE_CANONICALIZE_FILE_NAME''@|$(REPLACE_CANONICALIZE_FILE_NAME)|g' \
-e 's|@''REPLACE_MKSTEMP''@|$(REPLACE_MKSTEMP)|g' \
--- /dev/null
+Description:
+unlockpt() function: Unlock the slave side of a pseudo-terminal from its master
+side.
+
+Files:
+lib/unlockpt.c
+m4/unlockpt.m4
+
+Depends-on:
+stdlib
+extensions
+ptsname
+
+configure.ac:
+gl_FUNC_UNLOCKPT
+gl_STDLIB_MODULE_INDICATOR([unlockpt])
+
+Makefile.am:
+
+Include:
+<stdlib.h>
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
(const char *, char **, int));
#endif
+#if GNULIB_UNLOCKPT
+SIGNATURE_CHECK (GNULIB_NAMESPACE::unlockpt, int, (int));
+#endif
+
#if GNULIB_UNSETENV
SIGNATURE_CHECK (GNULIB_NAMESPACE::unsetenv, int, (const char *));
#endif