Giter Club home page Giter Club logo

Comments (6)

jtroo avatar jtroo commented on July 21, 2024 1

/dev/input/eventxx device is deleted when kanata exits. Not sure why though.

I would guess this is properly cleaned up and closed because the kernel knows about the kanata process and the fact that it has files related to the evdev interface open. So it's the kernel cleaning up as opposed to Rust code. This is in contrast to the symlink which is a filesystem concept independent of the input devices, so the kernel doesn't care to clean it up, and if the Rust code Drop handlers don't get called, it won't be cleaned up.

systemd by default use SIGTERM and SIGKILL to terminate a process which ctrlc cannot handle

The ctrlc does handle SIGTERM according to the documentation. Also, no crate gives the power to handle SIGKILL because the kernel never passes that signal onto the process; it just ends the process immediately. Just providing some clarification; the signal-hook crate is a fine choice as well.

from kanata.

jtroo avatar jtroo commented on July 21, 2024

Sure, could you say more about what about kanata's exit is not graceful? Would it need to catch an unwind and do some evdev cleanup before fully exiting?

from kanata.

jian-lin avatar jian-lin commented on July 21, 2024

Here is my WIP commit: jian-lin/kanata@c9427c9

The problem is symlink is not deleted after I Ctrl-C kanata.

Steps to reproduce:

  1. sudo ./target/debug/kanata --cfg cfg_samples/custom.kbd --symlink-name kanata
  2. type Ctrl-C after it starts
  3. /dev/input/by-id/kanata is a broken symlink, which ideally should be deleted

from kanata.

jtroo avatar jtroo commented on July 21, 2024

Right, the issue you've run into is that Rust does not guarantee that Drop implementations will be called for your code, which isn't specific to kanata. You'll need to add custom signal handlers for cleanup.

https://lib.rs/crates/ctrlc might be of help

from kanata.

jian-lin avatar jian-lin commented on July 21, 2024

Would it need to catch an unwind and do some evdev cleanup before fully exiting

/dev/input/eventxx device is deleted when kanata exits. Not sure why though.

You'll need to add custom signal handlers for cleanup. https://lib.rs/crates/ctrlc might be of help

Yeah, handling signals is a solution.

However I prefer signal-hook because:

  1. the symlink feature is linux-specific so ctrls's cross-platform ability is not needed
  2. systemd by default use SIGTERM and SIGKILL to terminate a process which ctrlc cannot handle

from kanata.

jtroo avatar jtroo commented on July 21, 2024

I don't think there's any issue in the repository that needs to be fixed, is that correct? Closing this issue, but feel free to re-open if I'm mistaken.

from kanata.

Related Issues (20)

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.