diff options
author | Jon Turney <jon.turney@dronecode.org.uk> | 2023-07-11 13:17:56 +0300 |
---|---|---|
committer | Jon Turney <jon.turney@dronecode.org.uk> | 2023-07-14 16:02:38 +0300 |
commit | 328258eba44993f05e6238c4c9b2124e2496fb4d (patch) | |
tree | 4b43abc5206a66c9f87070db9a6c7f12d3ef2256 /winsup/testsuite | |
parent | e8c1a579cdc5fc71b1aac1e747f6b10d4a1e8fd6 (diff) |
Cygwin: testsuite: Add a simple timeout mechanism
Astonishingly, we don't have this already, so tests which hang just stop
the testsuite dead in it's tracks...
Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
Diffstat (limited to 'winsup/testsuite')
-rw-r--r-- | winsup/testsuite/cygrun.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/winsup/testsuite/cygrun.c b/winsup/testsuite/cygrun.c index e6c4aa705..925b5513f 100644 --- a/winsup/testsuite/cygrun.c +++ b/winsup/testsuite/cygrun.c @@ -20,6 +20,7 @@ main (int argc, char **argv) { STARTUPINFO sa; PROCESS_INFORMATION pi; + DWORD res; DWORD ec = 1; char *p; @@ -42,9 +43,21 @@ main (int argc, char **argv) exit (1); } - WaitForSingleObject (pi.hProcess, INFINITE); + res = WaitForSingleObject (pi.hProcess, 60 * 1000); - GetExitCodeProcess (pi.hProcess, &ec); + if (res == WAIT_TIMEOUT) + { + char cmd[1024]; + // there is no simple API to kill a Windows process tree + sprintf(cmd, "taskkill /f /t /pid %lu", GetProcessId(pi.hProcess)); + system(cmd); + fprintf (stderr, "Timeout\n"); + ec = 124; + } + else + { + GetExitCodeProcess (pi.hProcess, &ec); + } CloseHandle (pi.hProcess); CloseHandle (pi.hThread); |