[libvirt] [RFC 1/2] process: wait longer 5->30s on hard shutdown

Christian Ehrhardt christian.ehrhardt at canonical.com
Fri Aug 3 06:29:40 UTC 2018


In cases where virProcessKillPainfully already reailizes that
SIGTERM wasn't enough we are partially on a bad path already.
Maybe the system is overloaded or having serious trouble to free and
reap resources in time.

In those case give the SIGKILL that was sent after 10 seconds some more
time to take effect if force was set (only then we are falling back to
SIGKILL anyway).

Signed-off-by: Christian Ehrhardt <christian.ehrhardt at canonical.com>
---
 src/util/virprocess.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/util/virprocess.c b/src/util/virprocess.c
index f92b0dce37..10952b0980 100644
--- a/src/util/virprocess.c
+++ b/src/util/virprocess.c
@@ -350,6 +350,7 @@ virProcessKillPainfully(pid_t pid, bool force)
 {
     size_t i;
     int ret = -1;
+    int maxwait = (force ? 200 : 75 );
     const char *signame = "TERM";
 
     VIR_DEBUG("vpid=%lld force=%d", (long long)pid, force);
@@ -357,12 +358,12 @@ virProcessKillPainfully(pid_t pid, bool force)
     /* This loop sends SIGTERM, then waits a few iterations (10 seconds)
      * to see if it dies. If the process still hasn't exited, and
      * @force is requested, a SIGKILL will be sent, and this will
-     * wait up to 5 seconds more for the process to exit before
+     * wait up to 30 seconds more for the process to exit before
      * returning.
      *
      * Note that setting @force could result in dataloss for the process.
      */
-    for (i = 0; i < 75; i++) {
+    for (i = 0; i < maxwait; i++) {
         int signum;
         if (i == 0) {
             signum = SIGTERM; /* kindly suggest it should exit */
-- 
2.17.1




More information about the libvir-list mailing list