From 75dea27979f0d219eed9c6afc3a721f592f7ca2a Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Thu, 25 Jul 2019 22:24:00 +0200 Subject: Terminate the unpacker child processes if the main process exits Should the main process exit (e.g. the user presses CTRL+C) or explcitily sends it a signal, the desired behaviour is for the children to stop unpacking and exit. This commit adds a line to configure the kernel to send SIGKILL to the children if their parent dies. The same option also exists on various BSDs (not all of them) but with a different name which has to be checked for and adjusted should the program be required to run on one of those. Signed-off-by: David Oberhollenzer --- unpack/fill_files.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'unpack/fill_files.c') diff --git a/unpack/fill_files.c b/unpack/fill_files.c index 865d050..88efd01 100644 --- a/unpack/fill_files.c +++ b/unpack/fill_files.c @@ -97,6 +97,9 @@ int fill_unpacked_files(fstree_t *fs, data_reader_t *data, int flags, pid = fork(); if (pid == 0) { + /* Kill the child when the parent process dies */ + prctl(PR_SET_PDEATHSIG, SIGKILL); + if (fill_files(data, sublists[i], flags)) exit(EXIT_FAILURE); exit(EXIT_SUCCESS); -- cgit v1.2.3