[v2,4/6,gdb/testsuite] Only retry on EEXIST in lock_file_acquire

Message ID 20260929110921.1910094-4-tdevries@suse.de
State New
Headers
Series [v2,1/6,gdb/testsuite] Add gdb.testsuite/lock.exp |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 success Build passed
linaro-tcwg-bot/tcwg_gdb_build--master-arm success Build passed

Commit Message

Tom de Vries Sept. 29, 2026, 11:09 a.m. UTC
  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(-)
  

Patch

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
 	}
     }