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

Event Issue after SIGSTOP #44

Open
ForbiddenEra opened this issue Apr 9, 2020 · 0 comments
Open

Event Issue after SIGSTOP #44

ForbiddenEra opened this issue Apr 9, 2020 · 0 comments

Comments

@ForbiddenEra
Copy link

When resuming from SIGSTOP, events aren't processed right / stdin isn't attached the same way?

So, for example, when you watch for events, CTRL-C, CTRL-Z don't work.. CTRL Z which sends SIGSTOP doesn't work - no problem, we just listen for CTRL-Z and send our own SIGSTOP message to our own PID to keep this functionality and we can even do some cleanup in our event handler.

Now, the issue appears when you resume the program - it DOES still listen for events, however it's like it's not attached/focused completely - CTRL-C and CTRL-Z will actually send their signals now. Other key events, you have to press ENTER for them to be picked up now - but they do still get picked up, even without re-assigning them.

I've tried just about everything, realloc(), program.listen(). It's like we need to reattach to stdin or something - except, as I said it does still process events, you just have to press enter after the keypress. Say you bind an event to 'x', press 'x' twice and hit enter, your event fires twice. The event should fire without pressing enter.

It's as if we're either setting a mode or changing how we read stdin or input at some point, I've been digging to try and find out where so I can either duplicate it in my own code or modify blessed to account for the reattachment.

Here's a testcase. Run it, pressing 'x' runs the event. Then press CTRL-Z, which runs the CTRL-Z event. You can see in this last example I even tried removing and resetting all handlers.

The ONLY way I've been able to get it to work is by doing program.destroy() and starting over, but then I would have to redraw all my windows/state/etc.

`#!/usr/bin/env node
"use strict";

const blessed = require('neo-blessed'),
program = blessed.program();

const screen = blessed.screen({
smartCSR: true
});

function setupHandlers() {
screen.key(['x'], (ch,key)=> {
console.log('xevent:');
console.log(ch);
console.log(key);
});

screen.key(['C-z'], (ch,key)=>{
console.log('stopevent- do cleanup here');
// screen.unkey(['x']);
// screen.unkey(['C-z']);
console.log(ch);
console.log(key);
process.kill(process.pid,'SIGSTOP');
});
}

setupHandlers();

program.hideCursor();

process.on('SIGCONT',(ev) => {
console.log(ev)
// setupHandlers();
// screen.enableInput();
// screen.realloc();
});
`

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

1 participant