diff -Nru stud-0.3/debian/changelog stud-0.3/debian/changelog --- stud-0.3/debian/changelog 2012-01-23 06:12:05.000000000 +0100 +++ stud-0.3/debian/changelog 2013-10-31 14:40:06.000000000 +0100 @@ -1,3 +1,11 @@ +stud (0.3-1ubuntu3) quantal; urgency=low + + * debian/patches/kill-children-on-sigterm.patch + Fix stud to handle termination of children processes + (LP: #1123950) + + -- Louis Bouchard Thu, 31 Oct 2013 14:39:43 +0100 + stud (0.3-1ubuntu2) precise; urgency=low * Disable non-portable local locking functions (using x86 assembly). diff -Nru stud-0.3/debian/patches/kill-children-on-sigterm.patch stud-0.3/debian/patches/kill-children-on-sigterm.patch --- stud-0.3/debian/patches/kill-children-on-sigterm.patch 1970-01-01 01:00:00.000000000 +0100 +++ stud-0.3/debian/patches/kill-children-on-sigterm.patch 2013-10-31 13:06:00.000000000 +0100 @@ -0,0 +1,59 @@ +Description: Fix to handle children termination + +Author: Louis Bouchard +Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/stud/+bug/1123950 +--- a/stud.c ++++ b/stud.c +@@ -1215,6 +1215,21 @@ + } + } + ++/* Handle children process termination. ++ Display error if needed but continue and ++ exits at the end of the list */ ++static void terminate_children() ++{ ++ int i = 0; ++ ++ for (i = 0; i < OPTIONS.NCORES; i++) { ++ if (kill(child_pids[i], SIGTERM) < 0) { ++ perror("stud:terminate_children - "); ++ } ++ } ++ exit(0); ++} ++ + void init_signals() { + struct sigaction act; + +@@ -1236,6 +1251,21 @@ + fail("sigaction - sigchld"); + } + ++ ++/* Enable specific SIGTERM handling by the parent proc ++ It becomes responsible for terminating children. */ ++void handle_sigterm() { ++ struct sigaction act; ++ ++ sigemptyset(&act.sa_mask); ++ act.sa_flags = 0; ++ ++ act.sa_handler = terminate_children; ++ ++ if (sigaction(SIGTERM, &act, NULL) < 0) ++ fail("sigaction - sigterm"); ++} ++ + /* Process command line args, create the bound socket, + * spawn child (worker) processes, and respawn if any die */ + int main(int argc, char **argv) { +@@ -1260,6 +1290,8 @@ + + start_children(0, OPTIONS.NCORES); + ++ handle_sigterm(); ++ + for (;;) { + /* Sleep and let the children work. + * Parent will be woken up if a signal arrives */ diff -Nru stud-0.3/debian/patches/series stud-0.3/debian/patches/series --- stud-0.3/debian/patches/series 2012-01-23 06:10:25.000000000 +0100 +++ stud-0.3/debian/patches/series 2013-10-31 13:02:18.000000000 +0100 @@ -1,2 +1,3 @@ binutils-gold.patch makefile-futex-disable.patch +kill-children-on-sigterm.patch