Code Monkey home page Code Monkey logo

Comments (5)

skull-squadron avatar skull-squadron commented on May 29, 2024

Confirmed, this is a show-stopper problem. We need WINCH and it should work. If it cannot catch these signals, it should not compile, but it should also be fixed. Silently broken is unprofessional fail.

@agatan Obviously, if you bothered to read the man pages, a correct call to pthread_sigmask is needed. A catchable signal must be not blocked, not ignored and have a registered handler to deliver it to.

from chan-signal.

euclio avatar euclio commented on May 29, 2024

I just ran into this as well. I don't understand, is this something that is fixable given the current architecture of the crate? I could try and open a PR.

from chan-signal.

Timmmm avatar Timmmm commented on May 29, 2024

Just run into this too. I think you are both right. You need to set the signals to be "blocked" and also not "ignored.

From man sigwait:

The signals specified by set should be blocked, but not ignored, at the time of the call to sigwait().

Processes which call sigwait() on ignored signals will wait indefinitely. Ignored signals are dropped immediately by the system, before delivery to a waiting process.

From man sigaction:

A process may specify a handler to which a signal is delivered, or specify that a signal is to be ignored.

From man pthread_sigmask:

Actually these man pages are about the most confusingly written I have ever read, but pthread_sigmask lets you set the "block" bit on a signal.

It would be good if this crate's Readme.md would mention that it doesn't... really.. work :-/

from chan-signal.

Timmmm avatar Timmmm commented on May 29, 2024

And upon reading the code it seems like it does block the signals properly, but just doesn't set any signal handlers.

A workaround in your code is something like this:

extern crate libc;
use libc::sighandler_t;
use libc::{c_int, c_void, SIGWINCH};
use libc::signal;

extern fn handler(_: c_int) {}

fn get_handler() -> sighandler_t {
    handler as extern fn(c_int) as *mut c_void as sighandler_t
}

fn main() {
	unsafe { signal(SIGWINCH, get_handler()); }
...

I have verified that this works and I now receive SIGNWINCH, however this should really be fixed in the library by doing the above for any signals the user requests.

from chan-signal.

BurntSushi avatar BurntSushi commented on May 29, 2024

This crate is now deprecated. See: https://users.rust-lang.org/t/ann-chan-is-deprecated-use-crossbeam-channel-instead/19251

from chan-signal.

Related Issues (14)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.