[GH-ISSUE #246] Background Execution #134

Closed
opened 2026-03-03 16:22:40 +03:00 by kerem · 5 comments
Owner

Originally created by @1995parham on GitHub (Oct 2, 2020).
Original GitHub issue: https://github.com/mum4k/termdash/issues/246

Is there any way to send a program to the background (with ctrl + z for example) then resume it? When I use this key combination on Linux nothing happens. Is there any suggestion for this?

Originally created by @1995parham on GitHub (Oct 2, 2020). Original GitHub issue: https://github.com/mum4k/termdash/issues/246 Is there any way to send a program to the background (with `ctrl + z` for example) then resume it? When I use this key combination on Linux nothing happens. Is there any suggestion for this?
kerem 2026-03-03 16:22:40 +03:00
  • closed this issue
  • added the
    question
    label
Author
Owner

@keithknott26 commented on GitHub (Oct 2, 2020):

I normally run it inside a screen session which works fine when you open the session back up

<!-- gh-comment-id:702925092 --> @keithknott26 commented on GitHub (Oct 2, 2020): I normally run it inside a screen session which works fine when you open the session back up
Author
Owner

@1995parham commented on GitHub (Oct 3, 2020):

By screen session, you mean something like tmux?

<!-- gh-comment-id:703046566 --> @1995parham commented on GitHub (Oct 3, 2020): By screen session, you mean something like `tmux`?
Author
Owner

@keithknott26 commented on GitHub (Oct 3, 2020):

on a linux host you can (provided screen is installed) and type "screen" which will open a new terminal inside your terminal... run your program, and then hit ctrl + a then "d" for detach. Then your program will run in the background, when you're ready to return to it just type "screen -x "

<!-- gh-comment-id:703050229 --> @keithknott26 commented on GitHub (Oct 3, 2020): on a linux host you can (provided screen is installed) and type "screen" which will open a new terminal inside your terminal... run your program, and then hit ctrl + a then "d" for detach. Then your program will run in the background, when you're ready to return to it just type "screen -x "
Author
Owner

@1995parham commented on GitHub (Oct 3, 2020):

Ok, I have got it. tmux is also like that. Thanks for mentioning. 👍 But in a case that I don't use it can we put it into the background?

<!-- gh-comment-id:703061636 --> @1995parham commented on GitHub (Oct 3, 2020): Ok, I have got it. `tmux` is also like that. Thanks for mentioning. :+1: But in a case that I don't use it can we put it into the background?
Author
Owner

@mum4k commented on GitHub (Oct 4, 2020):

Hi @1995parham and thank you @keithknott26 for providing the useful hint.

The reason ctrl+z doesn't work is that the underlying terminal library (tcell or termbox) captures all keyboard input. So the ctrl+z that is pressed is captured by Termdash instead of making it to the underlying shell that would then suspend the application.

If I remember correctly, what ctrl+z does is that it instructs the shell to send SIGTSTP to the process to essentially suspend it.

We could emulate the behavior by defining ctrl+z as a shortcut at the Termdash level. For that, you could implement a keyboard subscriber that will react to this shortcut being pressed. The reaction could be that the Go program will send SIGTSTP to itself. There is some example code : this Go issue: https://github.com/golang/go/issues/776#

Please let me know if you would like more details or if you have further questions.

<!-- gh-comment-id:703191139 --> @mum4k commented on GitHub (Oct 4, 2020): Hi @1995parham and thank you @keithknott26 for providing the useful hint. The reason ctrl+z doesn't work is that the underlying terminal library (tcell or termbox) captures all keyboard input. So the ctrl+z that is pressed is captured by Termdash instead of making it to the underlying shell that would then suspend the application. If I remember correctly, what ctrl+z does is that it instructs the shell to send SIGTSTP to the process to essentially suspend it. We could emulate the behavior by defining ctrl+z as a shortcut at the Termdash level. For that, you could implement a [keyboard subscriber](https://github.com/mum4k/termdash/wiki/Termdash-API#termdashkeyboardsubscriber) that will react to this shortcut being pressed. The reaction could be that the Go program will send SIGTSTP to itself. There is some example code : this Go issue: https://github.com/golang/go/issues/776# Please let me know if you would like more details or if you have further questions.
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/termdash#134
No description provided.