Skip to content
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

retry close() on EINTR? #229

Open
tkhattra opened this issue Nov 20, 2019 · 3 comments
Open

retry close() on EINTR? #229

tkhattra opened this issue Nov 20, 2019 · 3 comments

Comments

@tkhattra
Copy link

should close() be retried on EINTR in util/daemonize.c and util/entropy.c?

freebsd close(2) man page says: "In case of any error except EBADF, the supplied file descriptor is de-allocated and therefore is no longer valid."

linux close(2) man page also suggests not retrying close() in case of any error (except EINTR on HP-UX).

in a multi-threaded program, retrying close() may end up closing another thread's file descriptor (this is mentioned in linux close(2) man page too).

@cperciva
Copy link
Member

Yeah, we should probably change these. It's complicated since making close(2) work properly is very difficult (https://www.daemonology.net/blog/2011-12-17-POSIX-close-is-broken.html) although it is possible (https://twitter.com/cperciva/status/1141852451756105729).

I'm starting to think that I should just bite the bullet and implement the horrible-but-standards-compliant solution so I can stop worrying about this.

@tkhattra
Copy link
Author

wow, you already considered this many moons ago and solved it too - kudos!

@cperciva
Copy link
Member

Well... solved it in theory, at least. ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants