From 384b1c330ffbee4318ee75c97186450f0f6e9e35 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Sat, 31 Jul 2021 18:18:48 +0200 Subject: term: asynchronous client application termination MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When the foot window is closed, and we need to terminate the client application, do this in an asynchronous fashion: * Don’t do a blocking call to waitpid(), instead, rely on the reaper callback * Use a timer FD to implement the timeout before sending SIGKILL (instead of using SIGALRM). * Send SIGTERM immediately (we used to *just* close the PTY, and then wait 2 seconds before sending SIGTERM). * Raise the timeout from 2 seconds to 60 Full shutdown now depends on *two* asynchronous tasks - unmapping the window, and waiting for the client application to terminate. Only when *both* of these have completed do we proceed and call term_destroy(), and the user provided shutdown callback. --- terminal.h | 1 + 1 file changed, 1 insertion(+) (limited to 'terminal.h') diff --git a/terminal.h b/terminal.h index 688e42cc..e0441635 100644 --- a/terminal.h +++ b/terminal.h @@ -595,6 +595,7 @@ struct terminal { bool is_shutting_down; bool slave_has_been_reaped; + int slave_terminate_timeout_fd; int exit_status; void (*shutdown_cb)(void *data, int exit_code); void *shutdown_data; -- cgit v1.3