From 53d4999e7545bb4aed10787bcb0967fe2ad15f0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Harald=20J=C3=B6rg?= Date: Sun, 16 Feb 2025 16:41:26 +0100 Subject: [PATCH] unix/gtk.c: Make Prima's child process robust against signals Signals sent to the application propagate to the whole process group. If a Prima application handles / ignores a signal, the same signal can kill the child, which (correctly) discards any signal handlers set by the application. The patch puts the child in its own process group so that it does no longer receive signals sent to the parent process. This came up in a discussion on PDL: https://github.com/PDLPorters/pdl/pull/492 --- unix/gtk.c | 1 + 1 file changed, 1 insertion(+) diff --git a/unix/gtk.c b/unix/gtk.c index 32af5c27..f9ebe326 100644 --- a/unix/gtk.c +++ b/unix/gtk.c @@ -317,6 +317,7 @@ prima_gtk_init(void) if ( socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, gtk_screenshot_sockets) == 0) { gtk_screenshot_pid = fork(); if ( gtk_screenshot_pid == 0 ) { + (void) setsid(); close(gtk_screenshot_sockets[0]); run_screenshot_app(); exit(0);