Implementing signal handler: siginfo_t in libc for Linux does not contain si_addr field?

On Linux and Mac OS, siginfo_t contains a field si_addr to show which memory address caused this signal.
See sigaction(2) - Linux manual page
and Apple Developer Documentation.

However for Rust's libc crate, on Mac OS, siginfo_t contains a field of si_addr as expected ( But on linux, siginfo_t has no explicit si_addr field - it falls in one of the padding fields (

I don't quite understand the reason behind this. And I am wondering how I should access si_addr field on Linux (though I can access from some specific indices of the _pad field or create my own wrapper of siginfo_t for Linux, but this seems far away from a good solution).

Probably the person who wrote it didn't need the other fields.

Instead of writing a wrapper, you should modify libc source (GitHub - rust-lang/libc: Raw bindings to platform APIs for Rust) to add other fields and propose a PR. The maintainer is very responsive !

1 Like

Thanks a lot. I made some attempts to fix this but I met problems. I have submitted an issue on github:

1 Like