diff options
author | Eric Blake <eblake@redhat.com> | 2013-09-26 07:07:07 -0600 |
---|---|---|
committer | Eric Blake <eblake@redhat.com> | 2013-09-26 13:16:04 -0600 |
commit | fdd1b511c5c12912aae79b58e0c5f6ffa0492d6e (patch) | |
tree | 0e969daf7b52ec17b51d962720a5ec66fc9387aa /m4 | |
parent | 3bd0d48db800994cc10c3340c41d3242390dc68f (diff) | |
download | gnulib-fdd1b511c5c12912aae79b58e0c5f6ffa0492d6e.tar.gz |
dup2, dup3: work around another cygwin crasher
Cygwin 1.7.25 can crash due to an off-by-one bug on an attempt to
duplicate a file into the current RLIMIT_NOFILE soft limit, when
that limit is smaller than the hard limit. The intent in the
cygwin code was to allow the dup and auto-increase the soft limit,
which is itself questionable (and which we work around in the
gnulib getdtablesize module); but avoiding the crash is worth
doing even if the soft limit semantics are wrong.
http://cygwin.com/ml/cygwin/2013-09/msg00397.html
http://cygwin.com/ml/cygwin-developers/2013-q3/msg00010.html
* m4/dup2.m4 (gl_FUNC_DUP2): Expose the bug.
* m4/dup3.m4 (gl_FUNC_DUP3): Likewise.
* tests/test-dup2.c (main): Likewise.
* lib/dup2.c (rpl_dup2): Use setdtablesize to avoid it.
* lib/dup3.c (dup3): Likewise.
* doc/posix-functions/dup2.texi (dup2): Document it.
* doc/glibc-functions/dup3.texi (dup3): Likewise.
Signed-off-by: Eric Blake <eblake@redhat.com>
Diffstat (limited to 'm4')
-rw-r--r-- | m4/dup2.m4 | 7 | ||||
-rw-r--r-- | m4/dup3.m4 | 4 |
2 files changed, 7 insertions, 4 deletions
diff --git a/m4/dup2.m4 b/m4/dup2.m4 index 269cfdc112..dc3070c0d9 100644 --- a/m4/dup2.m4 +++ b/m4/dup2.m4 @@ -1,4 +1,4 @@ -#serial 19 +#serial 20 dnl Copyright (C) 2002, 2005, 2007, 2009-2013 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -39,9 +39,11 @@ AC_DEFUN([gl_FUNC_DUP2], /* Many gnulib modules require POSIX conformance of EBADF. */ if (dup2 (2, 1000000) == -1 && errno != EBADF) result |= 16; - /* Flush out a cygwin core dump. */ + /* Flush out some cygwin core dumps. */ if (dup2 (2, -1) != -1 || errno != EBADF) result |= 32; + dup2 (2, 255); + dup2 (2, 256); return result; ]) ], @@ -65,6 +67,7 @@ AC_DEFUN([gl_FUNC_DUP2], *yes) ;; *) REPLACE_DUP2=1 + AC_CHECK_FUNCS([setdtablesize]) ;; esac fi diff --git a/m4/dup3.m4 b/m4/dup3.m4 index 706d7261a2..23b6bb1a6a 100644 --- a/m4/dup3.m4 +++ b/m4/dup3.m4 @@ -1,4 +1,4 @@ -# dup3.m4 serial 4 +# dup3.m4 serial 5 dnl Copyright (C) 2009-2013 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -11,7 +11,7 @@ AC_DEFUN([gl_FUNC_DUP3], dnl Persuade glibc <unistd.h> to declare dup3(). AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) - AC_CHECK_FUNCS_ONCE([dup3]) + AC_CHECK_FUNCS_ONCE([dup3 setdtablesize]) if test $ac_cv_func_dup3 != yes; then HAVE_DUP3=0 fi |