diff options
| author | Colomban Wendling <[email protected]> | 2025-11-05 12:22:21 +0100 |
|---|---|---|
| committer | Victor Kareh <[email protected]> | 2025-11-14 18:00:26 -0500 |
| commit | b70d97e762a165828402307bca87221fdfa26d51 (patch) | |
| tree | a2b0ef8e6f19b1faaa04f8bafb5a6e12e4d02dc7 | |
| parent | c74d86d0f25435b1d90f70015d210448126bb6ef (diff) | |
| download | mate-utils-master.tar.bz2 mate-utils-master.tar.xz | |
Cleanly exit on SIGINT and SIGTERM so we can properly cleanup temporary
files.
| -rw-r--r-- | mate-screenshot/src/mate-screenshot.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/mate-screenshot/src/mate-screenshot.c b/mate-screenshot/src/mate-screenshot.c index b652f79a..df203a88 100644 --- a/mate-screenshot/src/mate-screenshot.c +++ b/mate-screenshot/src/mate-screenshot.c @@ -32,6 +32,8 @@ #include <unistd.h> #include <stdlib.h> #include <errno.h> +#include <signal.h> +#include <glib-unix.h> #ifdef ENABLE_NLS #include <locale.h> #endif /* ENABLE_NLS */ @@ -1270,6 +1272,14 @@ loop_dialog_screenshot (void) gtk_main (); } +static gboolean +signal_handler (gpointer data) +{ + /* exit cleanly on signals to allow cleaning up temporary files */ + gtk_main_quit (); + return FALSE; +} + /* main */ int main (int argc, char *argv[]) @@ -1363,6 +1373,9 @@ main (int argc, char *argv[]) if (delay_arg > 0) delay = delay_arg; + g_unix_signal_add (SIGINT, signal_handler, NULL); + g_unix_signal_add (SIGTERM, signal_handler, NULL); + loop_dialog_screenshot(); return EXIT_SUCCESS; |
