From: Tom de Vries <tdevries@suse.de>
To: gdb-patches@sourceware.org
Subject: [PATCH v2 4/6] [gdb/testsuite] Only retry on EEXIST in lock_file_acquire
Date: Tue, 29 Sep 2026 13:09:19 +0200 [thread overview]
Message-ID: <20260929110921.1910094-4-tdevries@suse.de> (raw)
In-Reply-To: <20260929110921.1910094-1-tdevries@suse.de>
It occurred to me that ignoring all errors in lock_file_acquire may be
undesirable.
Say you call lock_file_acquire with a lock file for which you have no
permission. You'd get an EACCESS. It doesn't make sense to keep retrying on
such an error.
Instead, only retry on the error that indicates that the lock is taken:
EEXIST.
---
gdb/testsuite/lib/gdb-utils.exp | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/gdb/testsuite/lib/gdb-utils.exp b/gdb/testsuite/lib/gdb-utils.exp
index 854496e9bb1..1277558170d 100644
--- a/gdb/testsuite/lib/gdb-utils.exp
+++ b/gdb/testsuite/lib/gdb-utils.exp
@@ -189,8 +189,8 @@ proc lock_file_acquire {lockfile} {
while {![info exists fh]} {
try {
set fh [open $lockfile {WRONLY CREAT EXCL}]
- } on error {} {
- # Ignore and try again.
+ } trap "POSIX EEXIST" {} {
+ # Lock in use. Ignore and try again. Propagate all other errors.
after 10
}
}
--
2.51.0
next prev parent reply other threads:[~2026-09-29 11:10 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-29 11:09 [PATCH v2 1/6] [gdb/testsuite] Add gdb.testsuite/lock.exp Tom de Vries
2026-09-29 11:09 ` [PATCH v2 2/6] [gdb/testsuite] Improve variable names in lock_file_{acquire, release} Tom de Vries
2026-09-29 11:09 ` [PATCH v2 3/6] [gdb/testsuite] Simplify lock_file_acquire Tom de Vries
2026-09-29 11:09 ` Tom de Vries [this message]
2026-09-29 11:09 ` [PATCH v2 5/6] [gdb/testsuite] Extend gdb.testsuite/lock.exp Tom de Vries
2026-09-29 11:09 ` [PATCH v2 6/6] [gdb/testsuite] Extend gdb.testsuite/lock.exp a bit more Tom de Vries
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=20260929110921.1910094-4-tdevries@suse.de \
--to=tdevries@suse.de \
--cc=gdb-patches@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: link
Be 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