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

fuse3: Set FD_CLOEXEC on duplicated fuse session fd #281

Merged
merged 1 commit into from
Apr 5, 2024

Conversation

gimaker
Copy link
Contributor

@gimaker gimaker commented Apr 4, 2024

The duplicated file descriptor returned by dup will not have FD_CLOEXEC flag set:

The two file descriptors do not share file descriptor flags (the close-on-exec flag). The close-on-exec flag (FD_CLOEXEC; see fcntl(2)) for the duplicate descriptor is off.

(The file descriptor returned by libfuse3 has FD_CLOEXEC set as of libfuse/libfuse@4a6fb67)

It's good practice to set the close-on-exec flag on file descriptors to avoid "leaking" fds when calling exec*().

@gimaker
Copy link
Contributor Author

gimaker commented Apr 4, 2024

Turns out this contributes to test flakiness for us - with enough test concurrency and leaking enough fds things go boom. There are other ways to fix our particular issue, but it seems apt to set FD_CLOEXEC on this fd.

(In addition from the "leaking" fd from fuser, libfuse3 also leaks another fd - 🙏 for setting FD_CLOEXEC for all fds in fuse_pure.rs!)

@cberner cberner merged commit bcff57c into cberner:master Apr 5, 2024
9 checks passed
@cberner
Copy link
Owner

cberner commented Apr 5, 2024

lgtm, thanks!

@gimaker gimaker deleted the dup-cloexec branch April 5, 2024 07:16
@gimaker
Copy link
Contributor Author

gimaker commented Apr 5, 2024

Thanks for the fast response time, appreciated!

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

Successfully merging this pull request may close these issues.

2 participants