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

Missing example for nix::sys::signal::SigHandler #319

Open
vi opened this issue Mar 17, 2016 · 7 comments
Open

Missing example for nix::sys::signal::SigHandler #319

vi opened this issue Mar 17, 2016 · 7 comments

Comments

@vi
Copy link
Contributor

vi commented Mar 17, 2016

I'm trying to write a signal handler that gets some usable value, with SigHandler::SigAction, but, for example, siginfo is stopping me right now:

extern "C" fn handle_sigint(_:i32, _ : ::nix::sys::signal::signal::siginfo, ptr : *mut  ::nix::sys::ioctl::libc::c_void)

->

error: failed to resolve. Could not find `signal` in `nix::sys::signal`
error: type name `nix::sys::signal::signal::siginfo` is undefined or not in scope

,

extern "C" fn handle_sigint(_:i32, _ : ::nix::sys::signal::siginfo, ptr : *mut ::nix::sys::ioctl::libc::c_void)

->

error: type name `nix::sys::signal::siginfo` is undefined or not in scope

How do I really do it?

In general working with signals using nix-rust feels like interfacing with C instead of using rustic wrappers... Are there any more high-level libraries? Maybe I just want chan_signal.

@kamalmarhubi
Copy link
Member

Thanks for the report! You have picked up on an issue of how close to the system APIs nix should be, which we've been discussing in #190. The current thinking is that the more rustic API you're describing would belong in an external library, possibly under the nix umbrella. The hypothetical nix-core would remain closer to the system.

In any case, a working example would be a great addition. @fiveop do you have any working code we could add in a doctest?

@fiveop
Copy link
Contributor

fiveop commented Mar 17, 2016

You would need to use the type libc::siginfo from the same libc version, that nix uses. There are still discussions on whether we should reexport libc or not. This is an example why I would prefer the latter, because the user has to deal with libc.

As much as we want to encapsulate libc functionality in a Rust idomatic way, at the end of the day the user has to write the signal handlers himself and thus deal with the low level function signatures, hence libc types.

@vi
Copy link
Contributor Author

vi commented Mar 17, 2016

I see explicit pub use of self::signal::siginfo in source code (available on [src] link in generated docs). I doesn't work for me somehow.

Are usual doctests embedded in the module (skipping visibility problems)?

@fiveop
Copy link
Contributor

fiveop commented Mar 17, 2016

That indicates that the docs are not up to date. Where do you look at the docs?

(Do we even publish new docs with a new version at the moment?)

@vi
Copy link
Contributor Author

vi commented Mar 17, 2016

@kamalmarhubi
Copy link
Member

Hrm, I wonder why the docs are not being updated. Opened #320.

In the meantime, for docs on the most recently released version on crates.io you can use crates.fyi: https://crates.fyi/crates/nix/

@Susurrus
Copy link
Contributor

Docs are generated on every release at docs.rs, so that's no longer an issue here. However, there is still the issue with docs being missing for nix::sys::signal::SigHandler. This would be a good situation for a new developer to come in and fix.

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

No branches or pull requests

4 participants