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

new InputEvent() hangs the terminal after closing node, needs kill -9 #21

Open
v934 opened this issue Oct 31, 2019 · 3 comments
Open

new InputEvent() hangs the terminal after closing node, needs kill -9 #21

v934 opened this issue Oct 31, 2019 · 3 comments

Comments

@v934
Copy link

v934 commented Oct 31, 2019

Hi,
I'm trying to use this package for my nodejs project running on an armv7 device with node v8.9.4.
I was amazed that it worked right away, without any problems. I can easily read events from /dev/input following the examples.

However I have one problem, when I close the node script (ctrl+c), my script itself stops working and I can even catch the SIGINT even telling it to stop, however after pressing ctrl+c, I cannot type anything into the terminal (nor press CTRL+C) anymore, it's stuck. The only way to stop is to execute killall -9 node and it frees the terminal.

It's caused solely by using new InputEvent('/dev/input/event0');, if I comment this line, it's not freezing anymore.

What can be the cause of this? Is there any way to fix it?

@yosefa11162198
Copy link

Have you try with "/dev/input/by-id/xxx"?

@stheine
Copy link

stheine commented Jan 1, 2020

I can confirm this bug(?). Even a process.exit() hangs. Somehow this is caused by the fs.createReadStream() that's not properly cleaned, even though .close() is called in inputEvent.close().

My workaround, sending a SIGTERM to myself on exit:

    process.on('exit', () => {
      // Workaround for the process not terminating on process.exit() due to input-event
      // calling fs.createReadStream() (which, for unknown reason, prevents exit).
      process.kill(process.pid, 'SIGTERM');
    });

@raintonr
Copy link

See nodejs/node@c6ec036

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

No branches or pull requests

4 participants