Mercurial > hg > octave-nkf > gnulib-hg
changeset 11894:6b94c8deb683
Tolerate declared but missing dup3 syscall.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Mon, 24 Aug 2009 00:56:31 +0200 |
parents | 476cefda5290 |
children | 3ef16b8c79cd |
files | ChangeLog lib/dup3.c lib/unistd.in.h m4/dup3.m4 modules/dup3 |
diffstat | 5 files changed, 26 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2009-08-23 Bruno Haible <bruno@clisp.org> + + Tolerate declared but missing dup3 syscall. + * lib/dup3.c (dup3): Invoke original dup3 function first, if available. + * lib/unistd.in.h (dup3): If the function is already present, + override it. + * m4/dup3.m4 (gl_FUNC_DUP3): Remove AC_LIBOBJ invocation. + * modules/dup3 (Makefile.am): Compile dup3.c always. + Reported by Paolo Bonzini. + 2009-08-23 Bruno Haible <bruno@clisp.org> Tolerate declared but missing pipe2 syscall.
--- a/lib/dup3.c +++ b/lib/dup3.c @@ -48,6 +48,17 @@ int dup3 (int oldfd, int newfd, int flags) { +#if HAVE_DUP3 +# undef dup3 + /* Try the system call first, if it exists. (We may be running with a glibc + that has the function but with an older kernel that lacks it.) */ + { + int result = dup3 (oldfd, newfd, flags); + if (!(result < 0 && errno == ENOSYS)) + return result; + } +#endif + if (oldfd < 0 || newfd < 0 || newfd >= getdtablesize ()) { errno = EBADF;
--- a/lib/unistd.in.h +++ b/lib/unistd.in.h @@ -179,7 +179,6 @@ #if @GNULIB_DUP3@ -# if !@HAVE_DUP3@ /* Copy the file descriptor OLDFD into file descriptor NEWFD, with the specified flags. The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>) @@ -188,8 +187,10 @@ Return newfd if successful, otherwise -1 and errno set. See the Linux man page at <http://www.kernel.org/doc/man-pages/online/pages/man2/dup3.2.html>. */ +# if @HAVE_DUP3@ +# define dup3 rpl_dup3 +# endif extern int dup3 (int oldfd, int newfd, int flags); -# endif #elif defined GNULIB_POSIXCHECK # undef dup3 # define dup3(o,n,f) \
--- a/m4/dup3.m4 +++ b/m4/dup3.m4 @@ -1,4 +1,4 @@ -# dup3.m4 serial 1 +# dup3.m4 serial 2 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, @@ -14,6 +14,5 @@ AC_CHECK_FUNCS_ONCE([dup3]) if test $ac_cv_func_dup3 != yes; then HAVE_DUP3=0 - AC_LIBOBJ([dup3]) fi ])