public inbox for cygwin-cvs@sourceware.org help / color / mirror / Atom feed
From: Jon Turney <jturney@sourceware.org> To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin] Cygwin: testsuite: Add a simple timeout mechanism Date: Fri, 14 Jul 2023 15:27:58 +0000 (GMT) [thread overview] Message-ID: <20230714152758.A3DAC3857718@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=328258eba44993f05e6238c4c9b2124e2496fb4d commit 328258eba44993f05e6238c4c9b2124e2496fb4d Author: Jon Turney <jon.turney@dronecode.org.uk> Date: Tue Jul 11 11:17:56 2023 +0100 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> Diff: --- winsup/testsuite/cygrun.c | 17 +++++++++++++++-- 1 file 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);
reply other threads:[~2023-07-14 15:27 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20230714152758.A3DAC3857718@sourceware.org \ --to=jturney@sourceware.org \ --cc=cygwin-cvs@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).