Mercurial > hg > octave-kai > gnulib-hg
changeset 11825:dcb923072f09
test-dup2: fix bad assumption
* tests/test-dup2.c (main): Tolerate leaked fds from environment.
Reported by Peter Breitenlohner <peb@mppmu.mpg.de>.
Signed-off-by: Eric Blake <ebb9@byu.net>
author | Eric Blake <ebb9@byu.net> |
---|---|
date | Thu, 13 Aug 2009 12:11:47 -0600 |
parents | 69c3e283e8de |
children | 278ae60991b9 |
files | ChangeLog tests/test-dup2.c |
diffstat | 2 files changed, 9 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2009-08-13 Eric Blake <ebb9@byu.net> + test-dup2: fix bad assumption + * tests/test-dup2.c (main): Tolerate leaked fds from environment. + Reported by Peter Breitenlohner <peb@mppmu.mpg.de>. + test-version-etc: fix CRLF portability issue * tests/test-version-etc.sh: Use tr, not sed, as not all sed recognize \r.
--- a/tests/test-dup2.c +++ b/tests/test-dup2.c @@ -67,8 +67,12 @@ char buffer[1]; int fd = open (file, O_CREAT | O_RDWR, 0600); - ASSERT (0 <= fd); + /* Assume std descriptors were provided by invoker. */ + ASSERT (STDERR_FILENO < fd); ASSERT (is_open (fd)); + /* Ignore any other fd's leaked into this process. */ + close (fd + 1); + close (fd + 2); ASSERT (!is_open (fd + 1)); ASSERT (!is_open (fd + 2));