From 4847aedde22b0026accbb71e5480ed353a330e02 Mon Sep 17 00:00:00 2001
From: Zack Galbreath <zack.galbreath@kitware.com>
Date: Thu, 18 Feb 2016 16:40:06 -0500
Subject: [PATCH] Process: Allow timeout to be changed after child starts

Recompute `TimeoutTime` after `Timeout` changes so that one may modify
the timeout of a process after it has started running by calling the
normal `kwsysProcess_SetTimeout` method.

Change-Id: I460a02d0d3c5f107b844abb56e39f5c844e7e3fb
---
 ProcessUNIX.c  | 2 ++
 ProcessWin32.c | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/ProcessUNIX.c b/ProcessUNIX.c
index 07c644b..7402955 100644
--- a/ProcessUNIX.c
+++ b/ProcessUNIX.c
@@ -505,6 +505,8 @@ void kwsysProcess_SetTimeout(kwsysProcess* cp, double timeout)
     {
     cp->Timeout = 0;
     }
+  // Force recomputation of TimeoutTime.
+  cp->TimeoutTime.tv_sec = -1;
 }
 
 /*--------------------------------------------------------------------------*/
diff --git a/ProcessWin32.c b/ProcessWin32.c
index eabd85f..a18ea27 100644
--- a/ProcessWin32.c
+++ b/ProcessWin32.c
@@ -698,6 +698,8 @@ void kwsysProcess_SetTimeout(kwsysProcess* cp, double timeout)
     {
     cp->Timeout = 0;
     }
+  // Force recomputation of TimeoutTime.
+  cp->TimeoutTime.QuadPart = -1;
 }
 
 /*--------------------------------------------------------------------------*/
-- 
GitLab