Skip to content

Suspend k9s using CTRL-Z#2484

Closed
arajski wants to merge 20 commits intoderailed:masterfrom
arajski:feat/support_ctrl_z
Closed

Suspend k9s using CTRL-Z#2484
arajski wants to merge 20 commits intoderailed:masterfrom
arajski:feat/support_ctrl_z

Conversation

@arajski
Copy link

@arajski arajski commented Jan 17, 2024

Description

Implements unix-like suspend functionality mentioned in #2013

At the moment, k9s supports Ctrl-C, which exits the application, however it's not possible to suspend the process and send it to the background. This PR implements that functionality, which is common among other tools, like vim.
User can now send the process to the background by pressing Ctrl-Z.
Once suspended, it can be resumed by either using fg or selecting a specific id from the jobs list (for example %1) in case there are multiple ones.

This behaviour can be enabled by setting allowSuspend to true.

Changes

  • remapped "Toggle Faults" action from Ctrl-Z to Ctrl-T (first one available that kind of made sense to me)
  • added suspend functionality to Ctrl-Z, which sends SIGTSTP signal to the current k9s process
  • added allowSuspend config to opt in to this behaviour
  • updated tests

TODO:

  • test on other platforms

Notes

This is my first contribution to this project, so happy to update things if there's anything missing/required. Thanks!

Copy link
Owner

@derailed derailed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@arajski Thanks for this update Artur!
Biggest concern with this behavior is to make sure we're cool all supported platforms.

@derailed derailed added enhancement New feature or request question Further information is requested needs-tlc Pr needs additional updates labels Jan 18, 2024
Copy link
Owner

@derailed derailed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@arajski Thank you for the updates Artur! LGTM
I think we need to test this out on linux, windows flavors, macOs.

@arajski
Copy link
Author

arajski commented Jan 24, 2024

@derailed seems like go doesn't support os signals on Windows without some hacky workarounds.
I was thinking about spawning a shell for anything other than linux and darwin OS.
From a user perspective it's going to look almost the same, except in order to return to k9s, you'll need to exit the shell instead of resuming the process from the background. Let me know if that makes sense.
Otherwise we can go with the subshell approach for everyone.

@derailed
Copy link
Owner

derailed commented Feb 3, 2024

@arajski Thank you for the research Artur! I think for non nix users likely Ctrtl-z does not make much sense. I don't use windows much these days but isn't Ctrl-z equivalent to undo?
If so might be best to detect the os and disable that functionality while in windows land?

@arajski arajski force-pushed the feat/support_ctrl_z branch from 9497cc0 to 33e727e Compare February 5, 2024 14:55
@arajski
Copy link
Author

arajski commented Feb 6, 2024

Done 👍 Tested on macOS Sonoma and Debian 12

@arajski arajski requested a review from derailed February 6, 2024 13:38
Copy link
Owner

@derailed derailed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@arajski Thanks for the checks and updates Artur.

@arajski arajski requested a review from derailed February 28, 2024 12:20
@derailed
Copy link
Owner

@arajski Looks much better. Thank you! Looks like we need to resolve a conflict...

@arajski
Copy link
Author

arajski commented Sep 7, 2024

@derailed sorry it took a while, conflict has been resolved. I noticed that you moved the quitCmd to the view package.
I didn't want to do anything out of context, but happy to also move this one as well if you think it's now more suitable.

@mghesh-yseop
Copy link

mghesh-yseop commented Aug 19, 2025

Hi @arajski and @derailed, still some conflicts ongoing. I'd love to see this feature merged 😄

@derailed
Copy link
Owner

derailed commented Sep 1, 2025

@arajski Can you take another peek (conflicts). Thank you!

@arajski
Copy link
Author

arajski commented Sep 10, 2025

@derailed all up to date 👍🏻

Copy link
Owner

@derailed derailed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@arajski Thank you for these updates!

@github-actions
Copy link

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions bot added the stale label Jan 15, 2026
@github-actions github-actions bot closed this Jan 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request needs-tlc Pr needs additional updates question Further information is requested stale

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants