From 994eecadb775bfc1a71a1829fb25e63a49a68132 Mon Sep 17 00:00:00 2001 From: Joss Wright Date: Mon, 12 Mar 2018 21:02:37 +0000 Subject: [PATCH] Adds close_on_child_death option for disowned processes. --- kitty/child-monitor.c | 2 +- kitty/config.py | 1 + kitty/kitty.conf | 6 ++++++ kitty/state.c | 1 + kitty/state.h | 1 + 5 files changed, 10 insertions(+), 1 deletion(-) diff --git a/kitty/child-monitor.c b/kitty/child-monitor.c index 015ce335c..7ca95bc5c 100644 --- a/kitty/child-monitor.c +++ b/kitty/child-monitor.c @@ -980,7 +980,7 @@ io_loop(void *data) { bool kill_signal = false, child_died = false; read_signals(fds[1].fd, &kill_signal, &child_died); if (kill_signal) { children_mutex(lock); kill_signal_received = true; children_mutex(unlock); } - if (child_died) reap_children(self, false); + if (child_died) reap_children(self, OPT(close_on_child_death)); } for (i = 0; i < self->count; i++) { if (fds[EXTRA_FDS + i].revents & (POLLIN | POLLHUP)) { diff --git a/kitty/config.py b/kitty/config.py index 829403a01..48f9336c8 100644 --- a/kitty/config.py +++ b/kitty/config.py @@ -272,6 +272,7 @@ type_map = { 'repaint_delay': positive_int, 'input_delay': positive_int, 'sync_to_monitor': to_bool, + 'close_on_child_death': to_bool, 'window_border_width': positive_float, 'window_margin_width': positive_float, 'window_padding_width': positive_float, diff --git a/kitty/kitty.conf b/kitty/kitty.conf index 268af8df6..a0698d93f 100644 --- a/kitty/kitty.conf +++ b/kitty/kitty.conf @@ -149,6 +149,12 @@ input_delay 3 # If so, set this to no. sync_to_monitor yes +# Close the terminal when the child process (shell) exits. If no, the terminal +# will remain open when the shell exits if processes are still outputting to +# the terminal. If yes, the terminal will close as soon as the child process +# exits regardless of processes outputting to the terminal. +close_on_child_death no + # Visual bell duration. Flash the screen when a bell occurs for the specified number of # seconds. Set to zero to disable. visual_bell_duration 0.0 diff --git a/kitty/state.c b/kitty/state.c index 458089c3c..28186f30b 100644 --- a/kitty/state.c +++ b/kitty/state.c @@ -352,6 +352,7 @@ PYWRAP1(set_options) { S(repaint_delay, repaint_delay); S(input_delay, repaint_delay); S(sync_to_monitor, PyObject_IsTrue); + S(close_on_child_death, PyObject_IsTrue); S(macos_option_as_alt, PyObject_IsTrue); S(macos_hide_titlebar, PyObject_IsTrue); diff --git a/kitty/state.h b/kitty/state.h index 235d3cdbf..7f55e9242 100644 --- a/kitty/state.h +++ b/kitty/state.h @@ -31,6 +31,7 @@ typedef struct { float inactive_text_alpha; Edge tab_bar_edge; bool sync_to_monitor; + bool close_on_child_death; } Options; typedef struct {