From 64be8b40f457f6480f9e79777d98afce40469786 Mon Sep 17 00:00:00 2001 From: =?utf8?q?P=C3=A1draig=20Brady?=
Date: Wed, 12 Sep 2012 03:21:11 +0100
Subject: [PATCH] timeout: handle signals more transparently
This was originally attempted in commit v8.12-117-g5a647a0,
but reverted before release because of the unreliability
of disabling core dumps using setrlimit() on Linux kernels.
This new version instead uses prctl() where available to
more reliably disable core dumps for the timeout process.
* m4/jm-macros.m4: Define HAVE_SETRLIMIT and HAVE_PRCTL.
* src/timeout.c (disable_core_dumps): A new function
that disables coredumps using prctl or setrlimit if available.
(main): If the child exited with a signal and we can
disable core dumps, then raise that signal to the timeout
process itself, so that callers may also see the signal status.
Also print a message indicating when the monitored command
dumped core, as that information is lost in the signal
propagation through timeout.
---
m4/jm-macros.m4 | 2 +-
src/timeout.c | 45 ++++++++++++++++++++++++++++++++-------------
2 files changed, 33 insertions(+), 14 deletions(-)
diff --git a/m4/jm-macros.m4 b/m4/jm-macros.m4
index 016172f..ff89aa3 100644
--- a/m4/jm-macros.m4
+++ b/m4/jm-macros.m4
@@ -64,7 +64,7 @@ AC_DEFUN([coreutils_MACROS],
# Used by sort.c.
AC_CHECK_FUNCS_ONCE([nl_langinfo])
# Used by timeout.c
- AC_CHECK_FUNCS_ONCE([setrlimit])
+ AC_CHECK_FUNCS_ONCE([setrlimit prctl])
# Used by tail.c.
AC_CHECK_FUNCS([inotify_init],
diff --git a/src/timeout.c b/src/timeout.c
index c0a2527..4ce18ad 100644
--- a/src/timeout.c
+++ b/src/timeout.c
@@ -49,6 +49,9 @@
#include