Message169405
| Author |
gregory.p.smith |
| Recipients |
cvrebert, ezio.melotti, gregory.p.smith, pitrou, rosslagerwall, sarum9in |
| Date |
2012年08月29日.18:21:08 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1346264472.12.0.137787965448.issue15798@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
Here's my initial fix.
If fcntl(errpipe_write, F_DUPFD, 3) is widely available this could be shrunk a bit to avoid the for loop potentially calling dup a few times and tracking the wasted fds to close later.
Otherwise if it isn't I'd rather not bother with F_DUPFD as this code takes the optimal path when F_DUPFD_CLOEXEC is supported (true on all modern linux systems) and should cause no harm beyond a couple extra dup and close syscalls otherwise.
Note: Linux pipe2() support appears in kernels a few revisions after F_DUPFD_CLOEXEC support so the good behavior when pipe2 exists will be kept in this situation as that also means F_DUPFD_CLOEXEC support should exist. The code will work regardless of that (incase someone has a frankenkernel, or other OSes choose to implement one but not the other). |
|