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

Allow use of CTRL-Z #16

Open
wallyqs opened this issue Sep 17, 2015 · 9 comments
Open

Allow use of CTRL-Z #16

wallyqs opened this issue Sep 17, 2015 · 9 comments
Assignees

Comments

@wallyqs
Copy link
Member

wallyqs commented Sep 17, 2015

It seems the framework is making it not possible to respond to some signals.

@derekcollison
Copy link
Member

Do you have a signal handler installed?

https://github.com/nats-io/gnatsd/blob/master/server/server.go#L146

@wallyqs
Copy link
Member Author

wallyqs commented Sep 17, 2015

The issue seems to be that the termui+termbox dependency which I added uses raw terminal input mode and also handles the signals instead, that is why they are ended up being disabled: https://github.com/nsf/termbox-go/blob/9914d1c528437633580e9aeda764bfb8c1415a9a/api.go#L305

@mcqueary
Copy link

Raw terminal mode just means no key bindings. From what I see, termbox is
only handling SIGWINCH and SIGIO. You could still keybind CTRL-z as
SIGTSTP, and install your own signal handler for SIGTSTP. (caveat: I only
looked at the code you linked. If other signals are actively being
blocked/ignored, I didn't see it.)

On Wed, Sep 16, 2015 at 10:56 PM, Waldemar Quevedo <notifications@github.com

wrote:

The issue seems to be that the termui+termbox dependency which I added
uses raw terminal input mode and also handles the signals instead, that is
why they are ended up being disabled:
https://github.com/nsf/termbox-go/blob/9914d1c528437633580e9aeda764bfb8c1415a9a/api.go#L305


Reply to this email directly or view it on GitHub
#16 (comment).

Larry McQueary | Director, Messaging Technology
larry@apcera.com | @mcqueary | github.com/mcqueary

@mcqueary
Copy link

If you do that, you might want to also handle SIGINT. I notice that top(1)
handles both SIGTSTP (CTRL-Z) and SIGINT (CTRL-C) in the usual way.

On Thu, Sep 17, 2015 at 12:27 PM, Larry McQueary larry@apcera.com wrote:

Raw terminal mode just means no key bindings. From what I see, termbox is
only handling SIGWINCH and SIGIO. You could still keybind CTRL-z as
SIGTSTP, and install your own signal handler for SIGTSTP. (caveat: I only
looked at the code you linked. If other signals are actively being
blocked/ignored, I didn't see it.)

On Wed, Sep 16, 2015 at 10:56 PM, Waldemar Quevedo <
notifications@github.com> wrote:

The issue seems to be that the termui+termbox dependency which I added
uses raw terminal input mode and also handles the signals instead, that is
why they are ended up being disabled:
https://github.com/nsf/termbox-go/blob/9914d1c528437633580e9aeda764bfb8c1415a9a/api.go#L305


Reply to this email directly or view it on GitHub
#16 (comment).

Larry McQueary | Director, Messaging Technology
larry@apcera.com | @mcqueary | github.com/mcqueary

Larry McQueary | Director, Messaging Technology
larry@apcera.com | @mcqueary | github.com/mcqueary

@wallyqs
Copy link
Member Author

wallyqs commented Sep 17, 2015

Thanks @mcqueary . Yes the issue seems to be that termbox is disabling syscall_ISIG which is required by SIGTSTP to work as intended.
https://github.com/nsf/termbox-go/blob/9914d1c528437633580e9aeda764bfb8c1415a9a/api.go#L62
Once removing the toggling of that flag in termbox, I was able to make, ctrl-z, fg work properly.

@mcqueary
Copy link

Ah -- good thing I included that caveat ;) Nice work.

On Thu, Sep 17, 2015 at 1:40 PM, Waldemar Quevedo notifications@github.com
wrote:

Thanks @mcqueary https://github.com/mcqueary . Yes the issue seems to
be that termbox is disabling syscall_ISIG which is required by SIGTSTP to
work as intended.

https://github.com/nsf/termbox-go/blob/9914d1c528437633580e9aeda764bfb8c1415a9a/api.go#L62
Once removing the toggling of that flag in termbox, I was able to make,
ctrl-z, fg work properly.


Reply to this email directly or view it on GitHub
#16 (comment).

@wallyqs
Copy link
Member Author

wallyqs commented Sep 18, 2015

Looked a bit into this one, and fix seems to be more involved than I thought. It is possible to allow suspending a process, but once the process resumes I should be handling SIGCONT to do so gracefully and currently Go 1.5.1 does not have a built-in way to handle it. There are alternatives for doing so by using cgo though: https://github.com/burke/go-sigcont

@mcqueary mcqueary changed the title Allow use of CTRL-Z Allow use of CTRL-Z Mar 20, 2016
@mcqueary
Copy link

@wallyqs did you ever implement this?

@wallyqs
Copy link
Member Author

wallyqs commented Mar 20, 2016

Haven't, though maybe possible to do so now since looks like SIGCONT handling is supported in Go 1.6 golang/go@81b3511

@mcqueary mcqueary added the ready label Mar 20, 2016
@bruth bruth removed the ready label Aug 18, 2023
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