[feat] Graceful shutdown
Nobody has claimed this yet.
- Dominant language
- OCaml
- Stars
- 472
- Forks
- 32
- PR merge metrics
- No merged PRs in 30d
Description
When starting a Mint Tea app, I enter the alt screen and hide the cursor like this:
let init _model = Command.(Seq [ Hide_cursor; Enter_alt_screen ])
When exiting, I restore their behaviour:
(* if we press `q` or the escape key, we exit *)
| Event.KeyDown ((Key "q" | Escape), _modifier) ->
( { model with exit = true },
Command.(Seq [ Exit_alt_screen; Show_cursor; Quit ]) )
However, if exit with Ctrl+C, then I'm still stuck in an alt screen with a hidden cursor.
I tried to exit gracefully myself by installing a signal handler like this:
let graceful_shutdown _sigint =
Tty.Escape_seq.exit_alt_screen_seq ();
Tty.Escape_seq.show_cursor_seq ();
exit 0
let set_sigint_handler () =
Sys.(set_signal sigint (Signal_handle graceful_shutdown))
let main () =
set_sigint_handler ();
This handles the signal but for some reason breaks my terminal completely (can't type anything, can't run anything).
I assume that Mint Tea wants to do some other clean up that I'm missing, so it would be really nice if this clean up functionality was exposed or if Mint Tea provided a way to configure graceful shutdown handlers.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the startup and shutdown commands shown in the issue, including Tty.Escape_seq and the main signal-handler setup. Determine what cleanup Ctrl-C requires beyond restoring the alt screen and cursor; done means Ctrl-C leaves the terminal usable while the existing q and Escape exit behavior continues to work.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ocaml
- Domain
- cli
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100