From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2201) id E303C3858D28; Thu, 25 Jan 2024 14:33:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E303C3858D28 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1706193184; bh=tPy6nY9GnL3SOP7jWxbpvNjoT0RPR9PeL0hpXpCAVs0=; h=From:To:Subject:Date:From; b=c44SZsALpsCiK++m0InO5X6QujVMhOWSymVC8K8q/EgJZdPboUAkP3OdNQLERnv0J lRJS0CdJ+KNuPdw5BJh/EsGOQl0422NBEogyzNbEi8o/RjHL5/rC+1UtO3wgpUdhic oDcNaZqie3EHb0dHwTBg7FKfHw4/RPASJe0aMn7Q= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Jon Turney To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin/main] Cygwin: Add a timeout to ensure we don't wait forever for dumper X-Act-Checkin: newlib-cygwin X-Git-Author: Jon Turney X-Git-Refname: refs/heads/main X-Git-Oldrev: 4d9808d404c21c73ff4f96547d2d5b6174323881 X-Git-Newrev: 1c13ca67b506df56c512d1a706eb6f45d9b4da38 Message-Id: <20240125143304.E303C3858D28@sourceware.org> Date: Thu, 25 Jan 2024 14:33:04 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dnewlib-cygwin.git;h=3D1c13ca67b50= 6df56c512d1a706eb6f45d9b4da38 commit 1c13ca67b506df56c512d1a706eb6f45d9b4da38 Author: Jon Turney 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); =20 + /* timeout from waiting for debugger to attach after 10 seconds */ + ULONGLONG timeout =3D 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. =20 Note that this is still racy: if the error_start process does it's wo= rk 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. */ =20 *dbg_end =3D 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); }