Check for definition of PR_SET_CHILD_SUBREAPER and don't die when it fails in order to degrade gracefully on older Linux versions that don't support this feature yet.
Fixes broken Bazel CI:
http://ci.bazel.io/job/bazel-docker-tests/532/BAZEL_VERSION=latest,PLATFORM_NAME=docker/console
@@ -177,10 +177,10 @@ void BecomeSubreaper() {
DIE("procctl");
}
#endif
-#if defined(__linux__)
- if (prctl(PR_SET_CHILD_SUBREAPER, 1) < 0) {
- DIE("prctl");
- }
+#if defined(PR_SET_CHILD_SUBREAPER)
+ // The "child subreaper" feature needs Linux 3.4 or higher.
+ // TODO(philwo) print a warning when this fails.
+ prctl(PR_SET_CHILD_SUBREAPER, 1);
#endif
}
