public inbox for cygwin-cvs@sourceware.org
help / color / mirror / Atom feed
* [newlib-cygwin/main] Cygwin: Add a timeout to ensure we don't wait forever for dumper
@ 2024-01-25 14:33 Jon Turney
0 siblings, 0 replies; only message in thread
From: Jon Turney @ 2024-01-25 14:33 UTC (permalink / raw)
To: cygwin-cvs
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=1c13ca67b506df56c512d1a706eb6f45d9b4da38
commit 1c13ca67b506df56c512d1a706eb6f45d9b4da38
Author: Jon Turney <jon.turney@dronecode.org.uk>
Date: Tue Jan 23 16:07:34 2024 +0000
Cygwin: Add a timeout to ensure we don't wait forever for dumper
Diff:
---
winsup/cygwin/exceptions.cc | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/winsup/cygwin/exceptions.cc b/winsup/cygwin/exceptions.cc
index 0e1a804ca..a2a6f9d4c 100644
--- a/winsup/cygwin/exceptions.cc
+++ b/winsup/cygwin/exceptions.cc
@@ -540,6 +540,9 @@ int exec_prepared_command (PWCHAR command)
}
FreeEnvironmentStringsW (rawenv);
+ /* timeout from waiting for debugger to attach after 10 seconds */
+ ULONGLONG timeout = GetTickCount64() + 10*1000;
+
console_printf ("*** starting '%W' for pid %u, tid %u\r\n",
command,
cygwin_pid (GetCurrentProcessId ()), GetCurrentThreadId ());
@@ -562,7 +565,8 @@ int exec_prepared_command (PWCHAR command)
we continue or not.
Note that this is still racy: if the error_start process does it's work too
- fast, we don't notice that it attached and get stuck here.
+ fast, we don't notice that it attached and get stuck here. So we also
+ apply a timeout to ensure we exit eventually.
*/
*dbg_end = L'\0';
@@ -570,7 +574,7 @@ int exec_prepared_command (PWCHAR command)
system_printf ("Failed to start, %E");
else
{
- while (!being_debugged ())
+ while (!being_debugged () && GetTickCount64() < timeout)
Sleep (0);
Sleep (2000);
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2024-01-25 14:33 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-25 14:33 [newlib-cygwin/main] Cygwin: Add a timeout to ensure we don't wait forever for dumper Jon Turney
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).