-
-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix fd leaks in fdopendir #29
Conversation
Somewhat on topic... I have no idea how macports works, but I see the port status of |
Thanks, I've added a link to your comment to https://trac.macports.org/ticket/58935#comment:33 which is where we are tracking the go failure on 10.9 and earlier. |
I updated my comment in the esbuild thread to reflect that the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple things to tweak. Otherwise, I think the changes do what you want & make sense to bring this function into conformity with standards-expected behavior.
src/fdopendir.c
Outdated
if (dirfd == AT_FDCWD) { | ||
dir = opendir ("."); | ||
/* dirfd can be closed only upon success */ | ||
if (dir && dirfd != -1) PROTECT_ERRNO(close(dirfd)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We knows here that dirfd != -1
(since it equals AT_FDCWD
, which is -2 according to sys/fcntl.h
), so that part can be removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM now; thx!
@kencu Any concerns with this PR? It allows the official go 1.15 release and any program created with it to work correctly on OSX 10.9.5 in file handle constrained environments. |
Sorry, I didn't see this before. I'll have to look it over and try it out on 10.4 to whereever it tops out to see what happens. In the meantime, you have made these changes on your own system I presume so you have that working for you. |
looks reasonable, thank you for the time you spent improving our legacy library. We have hopes that this will prove ever more useful for those of us with older Apple systems that are still useful hardware-wise, if abandoned software-wise by upstream. |
Thanks to everyone in macports who make this great software.
Would |
fdopendir
is supposed to take control of itsdirfd
parameter upon success.An unrelated edge case in error handling was also fixed to not leak memory and a fd.
See evanw/esbuild#348 for context.