X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Ffcntl.c;h=d6a328c1c01b409f667a6b020a79404ffdd81b55;hb=6b66ce308dae8448f02da645a9fd8fb992349f06;hp=25a79c5441d2d6e6372627ff626e3b23e06f1196;hpb=d60f3b0c6b0f93a601acd1cfd3923f94ca05abb0;p=gnulib.git diff --git a/lib/fcntl.c b/lib/fcntl.c index 25a79c544..d6a328c1c 100644 --- a/lib/fcntl.c +++ b/lib/fcntl.c @@ -187,7 +187,21 @@ rpl_fcntl (int fd, int action, /* arg */...) 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); + 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);