aboutsummaryrefslogtreecommitdiff
path: root/vis-subprocess.c
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fischer@muhq.space>2024-12-25 16:13:54 +0100
committerRandy Palamar <randy@rnpnr.xyz>2025-01-02 06:28:51 -0700
commitf6bb33cac458ba103ee2e94159bc7ae4e2fe2796 (patch)
tree3b1bd41c45f3c9a491177161d2293fcda5c88ab5 /vis-subprocess.c
parent9e5917823209f217f65c9b4c9d3ae7b2c45c9d2e (diff)
downloadvis-f6bb33cac458ba103ee2e94159bc7ae4e2fe2796.tar.gz
vis-f6bb33cac458ba103ee2e94159bc7ae4e2fe2796.tar.xz
check the life time of subprocesses before freeing vis
Currently there is now way for long running subprocesses like language servers to gracefully shutdown. When reacting to the QUIT event and invalidating the process handle the subprocess will never be killed and destroyed because the subprocesses are only checked during vis_run. Collecting and killing subprocesses with invalid handles after the QUIT event allows graceful shutdown.
Diffstat (limited to 'vis-subprocess.c')
-rw-r--r--vis-subprocess.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/vis-subprocess.c b/vis-subprocess.c
index 31a1479..e17d24f 100644
--- a/vis-subprocess.c
+++ b/vis-subprocess.c
@@ -230,3 +230,19 @@ void vis_process_tick(Vis *vis, fd_set *readfds) {
}
}
}
+
+/**
+ * Checks if each subprocess from the pool is dead or needs to be
+ * killed then raises an event or kills it if necessary.
+ */
+void vis_process_waitall(Vis *vis) {
+ for (Process **pointer = &process_pool; *pointer; ) {
+ Process *current = *pointer;
+ if (!wait_or_kill_process(vis, current)) {
+ pointer = &current->next;
+ } else {
+ /* update our iteration pointer */
+ *pointer = destroy_process(current);
+ }
+ }
+}