mrc0mmand / rpms / libguestfs

Forked from rpms/libguestfs 3 years ago
Clone

Blame SOURCES/0050-run-Use-timeout-foreground-option.patch

cd6068
From 2944df76a60d447cb81d47d3fb4d4952bc024c68 Mon Sep 17 00:00:00 2001
cd6068
From: "Richard W.M. Jones" <rjones@redhat.com>
cd6068
Date: Thu, 19 Dec 2013 08:21:53 +0000
cd6068
Subject: [PATCH] run: Use timeout --foreground option.
cd6068
cd6068
If timeout doesn't have this option (RHEL 6) don't use timeout at all.
cd6068
cd6068
Attempt to fix RHBZ#1025269.
cd6068
cd6068
(cherry picked from commit 681488877456b83f039dc518861f29ab4e1857f0)
cd6068
---
cd6068
 run.in | 12 ++++++------
cd6068
 1 file changed, 6 insertions(+), 6 deletions(-)
cd6068
cd6068
diff --git a/run.in b/run.in
cd6068
index 5ab008b..5a45888 100755
cd6068
--- a/run.in
cd6068
+++ b/run.in
cd6068
@@ -208,13 +208,13 @@ timeout_kill=30s
cd6068
 
cd6068
 # Do we have Padraig's timeout utility (from coreutils)?
cd6068
 if timeout --help >/dev/null 2>&1; then
cd6068
-    # Does this version of timeout have the -k option?  (Not on RHEL 6)
cd6068
-    if timeout -k 10s 10s true >/dev/null 2>&1; then
cd6068
-        timeout_k_opt="-k $timeout_kill"
cd6068
+    # Must use the --foreground option (RHBZ#1025269).
cd6068
+    if timeout --foreground 2 sleep 0 >/dev/null 2>&1; then
cd6068
+        # Does this version of timeout have the -k option?  (Not on RHEL 6)
cd6068
+        if timeout -k 10s 10s true >/dev/null 2>&1; then
cd6068
+            timeout="timeout -k $timeout_kill $timeout_period"
cd6068
+        fi
cd6068
     fi
cd6068
-    # Timeout (SIGTERM) after $timeout_period.
cd6068
-    # Then send a second SIGKILL $timeout_kill seconds later.
cd6068
-    timeout="timeout $timeout_k_opt $timeout_period"
cd6068
 fi
cd6068
 
cd6068
 pid=$$
cd6068
-- 
cd6068
1.8.3.1
cd6068