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

Fix the FD_CLOEXEC bit #10

Merged
merged 2 commits into from
Apr 22, 2024
Merged

Fix the FD_CLOEXEC bit #10

merged 2 commits into from
Apr 22, 2024

Conversation

mbuesch
Copy link
Sponsor Contributor

@mbuesch mbuesch commented Apr 21, 2024

FD_CLOEXEC is not a bit position. It's a bit mask already.

See the definition in the kernel:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/uapi/asm-generic/fcntl.h

and the use of that constant in:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/fs/fcntl.c

The current code in sd-notify is a no-op. Bit 1 is not looked at by the kernel. sd-notify does not touch bit 0.

Fix this by changing the mask.

FD_CLOEXEC is not a bit position. It's a bit mask already.

See the definition in the kernel:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/uapi/asm-generic/fcntl.h

and the use of that constant in:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/fs/fcntl.c

The current code in sd-notify is a no-op. Bit 1 is not looked at by the kernel.
sd-notify does not touch bit 0.

Fix this by changing the mask.
@lnicola
Copy link
Owner

lnicola commented Apr 22, 2024

Ouch, this is very embarrassing, thanks!

Can you also add a changelog entry?

@mbuesch
Copy link
Sponsor Contributor Author

mbuesch commented Apr 22, 2024

Thanks for your review. I added a changelog entry.

@lnicola lnicola merged commit 5f9cbef into lnicola:master Apr 22, 2024
1 check passed
@mbuesch
Copy link
Sponsor Contributor Author

mbuesch commented Apr 22, 2024

Meh, the changelog should have said Fixed instead of Changed, I guess. Sorry. Feel free to fix that when bumping the version number.

@mbuesch
Copy link
Sponsor Contributor Author

mbuesch commented May 5, 2024

One more question:
Do you plan to do a new release with this fix applied?

Thanks a lot for your time. :)

@lnicola
Copy link
Owner

lnicola commented May 5, 2024

Yes, I wanted to include #8, but I'll probably have to ping the author.

@mbuesch
Copy link
Sponsor Contributor Author

mbuesch commented May 5, 2024

Cool. Thanks. Take your time.

@lnicola
Copy link
Owner

lnicola commented May 5, 2024

In the meanwhile, another pair of eyes on that PR would be appreciated, just saying 😅.

@mbuesch
Copy link
Sponsor Contributor Author

mbuesch commented Jul 1, 2024

Hi

Is it possible to make a release with just this fix applied?
I'd like to release a dependent program. But that's not possible, if I'm on a git-dependency. So I would have to release without the fix. But I would like to include this fix, too.

Thanks a lot 👍

@lnicola
Copy link
Owner

lnicola commented Jul 2, 2024

Right, sorry. I'll try to do it tomorrow.

@lnicola
Copy link
Owner

lnicola commented Jul 3, 2024

Done, and sorry for the delays: https://crates.io/crates/sd-notify

@mbuesch
Copy link
Sponsor Contributor Author

mbuesch commented Jul 3, 2024

Thank you very much for your work. This really is an important and useful crate, IMO.

@lnicola
Copy link
Owner

lnicola commented Oct 11, 2024

Thanks, btw!

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