-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Bonjour Vincent,
Le 12/10/2013 10:07, Vincent Bernat a écrit : > Other solutions would be to provide Upstart/systemd scripts or to > modify stud to wait for its children before terminating. I can do a > patch for the later. > As expressed in my previous comment, here is a patch for stud that will handle the termination of the children started by stud's main process. If the patch is adequate, I will use the same one for Ubuntu. It would also be good to have it sent upstream, though there seems to be very limited activity over there. Kind regards, ...Louis - -- Louis Bouchard Software engineer, Cloud & Sustaining eng. Canonical Ltd Ubuntu support: http://canonical.com/support -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.14 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iEYEARECAAYFAlJpH8wACgkQDvqokHrhnCzq4wCg4OINezeEznK02Ia9PMvzIDY8 aIAAoPIwSIPdpqjxbFrY1r6ISQlQo88W =UhRR -----END PGP SIGNATURE-----
diff -Nru stud-0.3/debian/changelog stud-0.3/debian/changelog --- stud-0.3/debian/changelog 2013-06-08 23:11:29.000000000 +0200 +++ stud-0.3/debian/changelog 2013-10-24 15:09:09.000000000 +0200 @@ -1,3 +1,11 @@ +stud (0.3-5.1) sid; urgency=low + + * debian/patches/kill-children-on-sigterm.patch + Fix stud to handle termination of children processes + Closes: #725797 + + -- Louis Bouchard <[email protected]> Thu, 24 Oct 2013 14:54:19 +0200 + stud (0.3-5) unstable; urgency=low * Fix FTBFS when using --as-needed on non x86 arch. 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-24 15:23:45.000000000 +0200 @@ -0,0 +1,64 @@ +Description: Fix to handle children termination + +Author: Louis Bouchard <[email protected]> +Bug: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=725797 +Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/stud/+bug/1123950 +--- + +Index: stud-0.3/stud.c +=================================================================== +--- stud-0.3.orig/stud.c 2013-10-24 15:05:33.624471842 +0200 ++++ stud-0.3/stud.c 2013-10-24 15:07:41.504479870 +0200 +@@ -1217,6 +1217,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; + +@@ -1238,6 +1253,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) { +@@ -1262,6 +1292,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 2013-06-08 23:11:29.000000000 +0200 +++ stud-0.3/debian/patches/series 2013-10-24 15:07:28.000000000 +0200 @@ -2,3 +2,4 @@ enable-hardening.diff kfreebsd-no-keepidle.patch as-needed.patch +kill-children-on-sigterm.patch

