Mercurial > hg > octave-nkf > gnulib-hg
changeset 12396:85e0cbbf0787
cloexec: Fix possible compilation error.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Mon, 07 Dec 2009 01:02:50 +0100 |
parents | 9f528fc7a798 |
children | 799c920db2a5 |
files | ChangeLog lib/cloexec.c |
diffstat | 2 files changed, 10 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2009-12-06 Bruno Haible <bruno@clisp.org> + + * lib/cloexec.c (dup_cloexec): Fix handling of _gl_register_dup return + value. + 2009-12-06 Bruno Haible <bruno@clisp.org> * lib/progname.c: Include stdio.h, stdlib.h.
--- a/lib/cloexec.c +++ b/lib/cloexec.c @@ -79,7 +79,8 @@ prior to exec or spawn. Returns -1 and sets errno if FD could not be duplicated. */ -int dup_cloexec (int fd) +int +dup_cloexec (int fd) { int nfd; @@ -107,6 +108,7 @@ FALSE, /* InheritHandle */ DUPLICATE_SAME_ACCESS)) /* Options */ { + /* TODO: Translate GetLastError () into errno. */ errno = EMFILE; return -1; } @@ -133,12 +135,12 @@ nfd = fcntl (fd, F_DUPFD_CLOEXEC, 0); # if REPLACE_FCHDIR if (0 <= nfd) - result = _gl_register_dup (fd, nfd); + nfd = _gl_register_dup (fd, nfd); # endif # else /* !F_DUPFD_CLOEXEC */ nfd = dup (fd); - if (0 <= nfd && set_cloexec_flag (nfd, true)) + if (0 <= nfd && set_cloexec_flag (nfd, true) < 0) { int saved_errno = errno; close (nfd);