[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: fix mkostemp, add pipe2-safer
From: |
Bruno Haible |
Subject: |
Re: fix mkostemp, add pipe2-safer |
Date: |
Wed, 9 Dec 2009 11:22:43 +0100 |
User-agent: |
KMail/1.9.9 |
Hi Eric,
> > - In set_cloexec_flag: You added a call to
> > dup2 (desc, desc)
> > But on a POSIX compliant system this is a no-op, since
>
> Not quite. It is the fastest one-syscall sequence for determining whether
> an fd is open
Oh, I see. That wasn't clear to me.
> Okay, then, a comment describing that dup2 is used as an EBADF filter, and
> not for any side effects on cloexec (since there aren't any side effects),
> would make sense.
Yes. Two more comments won't harm:
2009-12-09 Bruno Haible <address@hidden>
* lib/cloexec.c (set_cloexec_flag): Clarify intent of dup2 call.
*** lib/cloexec.c.orig 2009-12-09 11:19:08.000000000 +0100
--- lib/cloexec.c 2009-12-09 10:55:55.000000000 +0100
***************
*** 71,78 ****
errno = EBADF;
return -1;
}
! return dup2 (desc, desc) == desc ? 0 : -1;
#endif
}
--- 71,82 ----
errno = EBADF;
return -1;
}
! if (dup2 (desc, desc) < 0)
! /* errno is EBADF here. */
! return -1;
+ /* There is nothing we can do on this kind of platform. Punt. */
+ return 0;
#endif
}