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

evdev device resources are not correctly released when kanata is killed by signals #54

Closed
jian-lin opened this issue Jul 21, 2022 · 2 comments
Labels
linux Issue pertains to Linux only question Further information is requested

Comments

@jian-lin
Copy link
Contributor

evdev device should call these functions to release resources before closing the device fd. They are wrapped by evdev-rs in the Drop trait.

Currently, the only way to terminate kanata is to kill it by a signal, e.g. SIGINT and SIGTERM.

Rust doesn't unwind and call drop() by default when receive SIGINT and SIGTERM, which causes those devices fail to release resources properly.

Relates to #46 , but I think this should be a separate issue and I cannot re-open that issue.

@jian-lin jian-lin changed the title evdev device resources are not correctly release when kanata is killed by signals evdev device resources are not correctly released when kanata is killed by signals Jul 21, 2022
@jtroo
Copy link
Owner

jtroo commented Jul 21, 2022

I'm not yet sure if what you're saying is correct for a terminating process.

Cleaning up using the functions you describe makes sense for a non-terminating process to not leak resources over time. However, for a terminating process, a non-buggy OS kernel must clean up after processes that die even if they did not do so themselves. Otherwise the kernel would run out of memory or file descriptors due to buggy programs or due to repeated killing via SIGKILL.

What specific resources are not cleaned up correctly? In the previous issue you mentioned a symlink, but if I understand correctly that was unrelated to evdev so that one is not relevant for this bug.

@jtroo jtroo added question Further information is requested linux Issue pertains to Linux only labels Jul 21, 2022
@jian-lin
Copy link
Contributor Author

You are probably right about the cleaning stuff done by OS. And if you are right, there is no issue with current kanata.

What specific resources are not cleaned up correctly?

I have no idea what resources are needed by evdev devices.

In the previous issue you mentioned a symlink

Yeah, I come across this "issue" when I think about cleaning a symlink in the signal handler. I missed the point that OS should clean evdev resources for terminated kanata.

Sorry for the noise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
linux Issue pertains to Linux only question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants