projects
/
gnulib.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
openat: work around AIX 7.1 fstatat bug
[gnulib.git]
/
lib
/
fcntl.c
diff --git
a/lib/fcntl.c
b/lib/fcntl.c
index
05d73a9
..
d6a328c
100644
(file)
--- a/
lib/fcntl.c
+++ b/
lib/fcntl.c
@@
-1,6
+1,6
@@
/* Provide file descriptor control.
/* Provide file descriptor control.
- Copyright (C) 2009 Free Software Foundation, Inc.
+ Copyright (C) 2009
-2011
Free Software Foundation, Inc.
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
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
@@
-25,6
+25,7
@@
#include <errno.h>
#include <limits.h>
#include <stdarg.h>
#include <errno.h>
#include <limits.h>
#include <stdarg.h>
+#include <unistd.h>
#if !HAVE_FCNTL
# define rpl_fcntl fcntl
#if !HAVE_FCNTL
# define rpl_fcntl fcntl
@@
-186,7
+187,21
@@
rpl_fcntl (int fd, int action, /* arg */...)
errno = EINVAL;
else
{
errno = EINVAL;
else
{
+ /* Haiku alpha 2 loses fd flags on original. */
+ int flags = fcntl (fd, F_GETFD);
+ if (flags < 0)
+ {
+ result = -1;
+ break;
+ }
result = fcntl (fd, action, target);
result = fcntl (fd, action, target);
+ if (0 <= result && fcntl (fd, F_SETFD, flags) == -1)
+ {
+ int saved_errno = errno;
+ close (result);
+ result = -1;
+ errno = saved_errno;
+ }
# if REPLACE_FCHDIR
if (0 <= result)
result = _gl_register_dup (fd, result);
# if REPLACE_FCHDIR
if (0 <= result)
result = _gl_register_dup (fd, result);