[GH-ISSUE #984] Doesn't revert to shell after receiving SIGTSTP #712

Closed
opened 2026-03-04 01:07:12 +03:00 by kerem · 3 comments
Owner

Originally created by @pafoster on GitHub (May 5, 2024).
Original GitHub issue: https://github.com/rivo/tview/issues/984

First off, thanks for developing this amazing library!

Unexpected behaviour: If I issue a kill -s SIGTSTP $pid as a command in a separate terminal, the terminal running the UI continues to display the UI (albeit in SIGTSTPed state). Expected behaviour (see top, links and other utilities) is for the running process to revert to the user's shell.

Related question: How do I ensure that Ctrl-Z triggers a SIGTSTP?

Originally created by @pafoster on GitHub (May 5, 2024). Original GitHub issue: https://github.com/rivo/tview/issues/984 First off, thanks for developing this amazing library! Unexpected behaviour: If I issue a `kill -s SIGTSTP $pid` as a command in a separate terminal, the terminal running the UI continues to display the UI (albeit in SIGTSTPed state). Expected behaviour (see `top`, `links` and other utilities) is for the running process to revert to the user's shell. Related question: How do I ensure that Ctrl-Z triggers a SIGTSTP?
kerem closed this issue 2026-03-04 01:07:13 +03:00
Author
Owner

@rivo commented on GitHub (May 9, 2024):

I wonder if this is more of a question for tcell than for this project. Definitely the last question because my understanding is that tcell will capture all user input, including Ctrl-Z. For example, this is bound to the "undo" function in a TextArea.

There is Application.Suspend() also which might help you achieve what you would like to do. And if it doesn't, please explain why/how receiving SIGTSTP (and SIGCONT also, I assume) is something your application needs to be able to support.

<!-- gh-comment-id:2102557214 --> @rivo commented on GitHub (May 9, 2024): I wonder if this is more of a question for [`tcell`](https://github.com/gdamore/tcell) than for this project. Definitely the last question because my understanding is that `tcell` will capture all user input, including <kbd>Ctrl-Z</kbd>. For example, this is bound to the "undo" function in a `TextArea`. There is [`Application.Suspend()`](https://pkg.go.dev/github.com/rivo/tview#Application.Suspend) also which might help you achieve what you would like to do. And if it doesn't, please explain why/how receiving `SIGTSTP` (and `SIGCONT` also, I assume) is something your application needs to be able to support.
Author
Owner

@pafoster commented on GitHub (May 18, 2024):

Thank you. What I'd like to achieve is to signal that the process running the tview application is suspended, taking me back to the shell from which the process was invoked. You can reproduce this effect by invoking a utility like top in your terminal and hitting ctrl-z. What happens is that it temporarily suspends execution of the process and takes you back to the shell; if you then type fg, top will display again and continue execution. I am providing top as an example for what I believe is standard behaviour for job control in a Unix/Linux environment.

According to https://www.gnu.org/software/libc/manual/html_node/Job-Control-Signals.html:

The SIGTSTP signal is an interactive stop signal. Unlike SIGSTOP, this signal can be handled and ignored.

Your program should handle this signal if you have a special need to leave files or system tables in a secure state when a process is stopped. For example, programs that turn off echoing should handle SIGTSTP so they can turn echoing back on before stopping.

This signal is generated when the user types the SUSP character (normally C-z). For more information about terminal driver support, see Special Characters.

The typical behavior is described in this stackexchange post:

Pressing ctrl + z sends the TSTP signal to your process. This halts execution (the kernel won't schedule any more CPU time to the process) and the process is awaiting a CONT to continue processing.

You can emulate/replicate this via kill -TSTP and kill -CONT (since kill will send a nominated signal to your process, despite the name!)

I've used Application.Suspend() successfully to invoke a sub-shell. But what I am after here as mentioned above, is to a) temporarily suspend execution on the process and b) return to the shell from which the process was invoked.

The Wikipedia article on job control says:

A job running in the foreground can be stopped by typing the suspend character (Ctrl-Z). This sends the "terminal stop" signal (SIGTSTP) to the process group. By default, SIGTSTP causes processes receiving it to stop, and control is returned to the shell. However, a process can register a signal handler for or ignore SIGTSTP. A process can also be paused with the "stop" signal (SIGSTOP), which cannot be caught or ignored.

<!-- gh-comment-id:2118875213 --> @pafoster commented on GitHub (May 18, 2024): Thank you. What I'd like to achieve is to signal that the process running the tview application is suspended, taking me back to the shell from which the process was invoked. You can reproduce this effect by invoking a utility like `top` in your terminal and hitting ctrl-z. What happens is that it temporarily suspends execution of the process and takes you back to the shell; if you then type `fg`, `top` will display again and continue execution. I am providing `top` as an example for what I believe is standard behaviour for job control in a Unix/Linux environment. According to https://www.gnu.org/software/libc/manual/html_node/Job-Control-Signals.html: > The SIGTSTP signal is an interactive stop signal. Unlike SIGSTOP, this signal can be handled and ignored. > Your program should handle this signal if you have a special need to leave files or system tables in a secure state when a process is stopped. For example, programs that turn off echoing should handle SIGTSTP so they can turn echoing back on before stopping. > This signal is generated when the user types the SUSP character (normally C-z). For more information about terminal driver support, see [Special Characters](https://www.gnu.org/software/libc/manual/html_node/Special-Characters.html). The typical behavior is described in [this stackexchange post](https://superuser.com/questions/476873/what-is-effect-of-ctrl-z-on-a-unix-linux-application): > Pressing ctrl + z sends the [TSTP](http://en.wikipedia.org/wiki/SIGTSTP) signal to your process. This halts execution (the kernel won't schedule any more CPU time to the process) and the process is awaiting a CONT to continue processing. > You can emulate/replicate this via kill -TSTP and kill -CONT (since kill will send a nominated signal to your process, despite the name!) I've used [Application.Suspend()](https://pkg.go.dev/github.com/rivo/tview#Application.Suspend) successfully to invoke a sub-shell. But what I am after here as mentioned above, is to a) temporarily suspend execution on the process and b) return to the shell from which the process was invoked. The [Wikipedia article on job control](https://en.wikipedia.org/wiki/Job_control_(Unix)#Implementation) says: > A job running in the foreground can be stopped by typing the suspend character ([Ctrl-Z](https://en.wikipedia.org/wiki/Ctrl-Z)). This sends the "terminal stop" [signal](https://en.wikipedia.org/wiki/Signal_(computing)) (SIGTSTP) to the process group. By default, SIGTSTP causes processes receiving it to stop, and control is returned to the shell. However, a process can register a signal handler for or ignore SIGTSTP. A process can also be paused with the "stop" signal (SIGSTOP), which cannot be caught or ignored.
Author
Owner

@pafoster commented on GitHub (Dec 8, 2024):

Closing this issue as this is likely lower-level than tview. (I've reported a possibly related issue here: https://github.com/golang/go/issues/70548)

<!-- gh-comment-id:2526295729 --> @pafoster commented on GitHub (Dec 8, 2024): Closing this issue as this is likely lower-level than tview. (I've reported a possibly related issue here: https://github.com/golang/go/issues/70548)
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/tview#712
No description provided.