Skip to content

Consistent wrapper over siginfo_t #1051

Open
@gnzlbg

Description

@gnzlbg

The API of the libc::signinfo_t type is platform dependent, and currently nix exposes this type "as is" to users.

For example, on many OSes (MacOS, *BSDs, etc.) siginfo_t is a struct that has a si_addr struct field, but on Linux, for example, si_addr is not a struct field. Instead, linux contains an union fields, that has some more fields, that have some more fields, and one of them is si_addr. Linux provides a C macro to access this field, and in libc we provide a method on siginfo_t for that.

This means that, depending on the target platform, users using the siginfo_t type re-exported by nix need to perform either field access, or call a method, which is not very consistent.

si_addr is not the only siginfo_t field which is different on Linux.


One idea would be for nix to just have a #[repr(transparent)] struct siginfo_t(libc::siginfo_t); type wrapper that always exposes methods instead, and to use #[cfg]s inside the methods to map to whatever layout the operating system being targeted uses.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions