Skip to content

Expose si_pid and si_uid from siginfo_t as functions #1858

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

Merged
merged 3 commits into from
Aug 11, 2020

Conversation

joshtriplett
Copy link
Member

On Linux, siginfo_t cannot expose these fields directly due to
#716 , so expose them as
functions, just like si_addr and si_value.

Provide the same functions on other platforms that have these fields
declared, for consistency.

@rust-highfive
Copy link

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @JohnTitor (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@joshtriplett
Copy link
Member Author

Pushed a new version to fix structure alignment.

@joshtriplett
Copy link
Member Author

Currently reworking this a bit more, to handle the alignment correctly on both 64-bit and 32-bit platforms.

@joshtriplett joshtriplett force-pushed the siginfo-pid-uid branch 2 times, most recently from 9ec238c to e3fbc3b Compare August 10, 2020 06:02
@joshtriplett
Copy link
Member Author

Re-pushed with style issue (line length) fixed. Simplified in the process.

@joshtriplett
Copy link
Member Author

Alright, looks like just two builds failed here this time.

mipsel-unknown-linux-musl appears spurious: it failed to download something. Needs a retry.

And the builder running rust 1.13 failed, because rust 1.13 didn't support union. I'll switch the pre-existing functions back to not use union, and make the new functions conditional on #[cfg(libc_union)].

On Linux, siginfo_t cannot expose these fields directly due to
rust-lang#716 , so expose them as
functions, just like si_addr and si_value.

In order to get alignment correct on both 32-bit and 64-bit
architectures, define an sifields union that includes a pointer field,
to ensure that it has the same alignment as a pointer.
@joshtriplett
Copy link
Member Author

Fixed style for conditional compilation.

@joshtriplett
Copy link
Member Author

This now passes CI everywhere.

…3 fields

The first 3 fields of `siginfo_t` have different orders on MIPS. When
casting `siginfo_t` to a different type to access the fields of the
`sifields` union, avoid giving names to the first three fields, since
they're only present for memory layout and shouldn't be accessed from
the casted structure type.
The SIGCHLD variant of the siginfo structure also provides fields for
user and system time; expose those as well.
Copy link
Contributor

@pickfire pickfire left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. I am not very well versed with this and only reviewed linux-like stuff so I think it would be better to have another reviewer.

Copy link
Member

@JohnTitor JohnTitor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks!

@JohnTitor JohnTitor merged commit 6ff0689 into rust-lang:master Aug 11, 2020
@joshtriplett joshtriplett deleted the siginfo-pid-uid branch August 11, 2020 19:59
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.

4 participants