Merge authors:
Stéphane Graber (stgraber)
Related merge proposals:
https://code.launchpad.net/~stgraber/upstart/upstart-prctl/+merge/136759
proposed by: Stéphane Graber (stgraber)
------------------------------------------------------------
revno: 1407 [merge]
committer: James Hunt <[email protected]>
branch nick: upstart
timestamp: Mon 2012-12-17 09:23:43 +0000
message:
* Merge of lp:~stgraber/upstart/upstart-prctl.
modified:
configure.ac
init/log.c
init/main.c
init/tests/test_log.c
init/tests/test_state.c
--
lp:upstart
https://code.launchpad.net/~upstart-devel/upstart/trunk
Your team Upstart Reviewers is subscribed to branch lp:upstart.
To unsubscribe from this branch go to
https://code.launchpad.net/~upstart-devel/upstart/trunk/+edit-subscription
=== modified file 'configure.ac'
--- configure.ac 2012-12-07 20:33:03 +0000
+++ configure.ac 2012-12-07 21:39:17 +0000
@@ -53,7 +53,7 @@
AM_CONDITIONAL([HAVE_UDEV], [test "$have_udev" = yes])
# Checks for header files.
-AC_CHECK_HEADERS([valgrind/valgrind.h])
+AC_CHECK_HEADERS([valgrind/valgrind.h, sys/prctl.h])
# Checks for typedefs, structures, and compiler characteristics.
AC_PROG_CC_C99
=== modified file 'init/log.c'
--- init/log.c 2012-11-23 11:36:47 +0000
+++ init/log.c 2012-12-07 21:38:17 +0000
@@ -31,7 +31,6 @@
#include "session.h"
#include "conf.h"
#include "paths.h"
-#include <sys/prctl.h>
static int log_file_open (Log *log);
static int log_file_write (Log *log, const char *buf, size_t len);
=== modified file 'init/main.c'
--- init/main.c 2012-11-07 15:17:58 +0000
+++ init/main.c 2012-12-07 21:39:17 +0000
@@ -30,6 +30,13 @@
#include <sys/resource.h>
#include <sys/mount.h>
+#ifdef HAVE_SYS_PRCTL_H
+#include <sys/prctl.h>
+#ifndef PR_SET_CHILD_SUBREAPER
+#define PR_SET_CHILD_SUBREAPER 35
+#endif
+#endif
+
#include <errno.h>
#include <stdio.h>
#include <limits.h>
@@ -603,6 +610,19 @@
if (disable_sessions)
nih_debug ("Sessions disabled");
+ /* Set us as the child subreaper.
+ * This ensures that even when init doesn't run as PID 1, it'll always be
+ * the ultimate parent of everything it spawns. */
+
+#ifdef HAVE_SYS_PRCTL_H
+ if (getpid () > 1 && prctl (PR_SET_CHILD_SUBREAPER, 1) < 0) {
+ nih_warn ("%s: %s", _("Unable to register as subreaper"),
+ strerror (errno));
+
+ NIH_MUST (event_new (NULL, "child-subreaper-failed", NULL));
+ }
+#endif
+
/* Run through the loop at least once to deal with signals that were
* delivered to the previous process while the mask was set or to
* process the startup event we emitted.
=== modified file 'init/tests/test_log.c'
--- init/tests/test_log.c 2012-09-20 08:12:05 +0000
+++ init/tests/test_log.c 2012-12-07 21:38:17 +0000
@@ -26,7 +26,6 @@
#include <libgen.h>
#include <sys/types.h>
#include <sys/ioctl.h>
-#include <sys/prctl.h>
#include <nih/test.h>
#include <nih/timer.h>
#include <nih/child.h>
=== modified file 'init/tests/test_state.c'
--- init/tests/test_state.c 2012-12-04 16:09:18 +0000
+++ init/tests/test_state.c 2012-12-07 21:38:17 +0000
@@ -28,7 +28,6 @@
#include <libgen.h>
#include <sys/types.h>
#include <sys/ioctl.h>
-#include <sys/prctl.h>
#include <nih/test.h>
#include <nih/timer.h>
#include <nih/child.h>
--
upstart-devel mailing list
[email protected]
Modify settings or unsubscribe at:
https://lists.ubuntu.com/mailman/listinfo/upstart-devel