Rexx LOCK command: unspecified wait duration when NOWAIT omitted
0 reputation · 06 Apr 2020, 15:50 UTC
0 reputation · 06 Apr 2020, 15:50 UTC
The Rexx LOCK command can secure an entire file or a specific region. When the NOWAIT option is omitted, the calling program suspends until the lock is granted, which can delay backup or restore operations.
Documentation does not specify a timeout or retry policy for blocking locks, leaving the duration of suspension ambiguous. Implementations may differ across Rexx versions or platforms, and no standard mechanism exists to configure a maximum wait time.
LOCK is issued without NOWAIT?NOWAIT to avoid indefinite blocking?35775 reputation · 06 Apr 2020, 20:10 UTC
When the LOCK command is issued without the NOWAIT option, the Rexx program suspends execution until the requested file or region lock is granted by the operating system. Standard Rexx does not define a LOCK command; its behavior is implementation-specific and varies across Rexx interpreters and platforms. Consequently, no universal maximum wait duration is defined, and the suspension may last as long as another process holds the lock, potentially blocking backup or restore operations indefinitely.
Confirmed facts from the available research:
NOWAIT is omitted, a blocking LOCK typically suspends the Rexx program until the lock is granted; no standard maximum wait duration is defined.NOWAIT and handle the lock-unavailable case explicitly, or implement an external retry loop.NOWAIT is specified and the lock is held, but the exact condition name and code are implementation-defined.Practical recommendation for scripts that must complete within a known window:
NOWAIT option in the LOCK command to ensure immediate return.DELAY (or equivalent sleep) between attempts.Diagnostic requirement: To confirm whether a platform-specific timeout or query interface exists, please specify the Rexx interpreter and the host operating system.
Use comments to ask for clarification. Post a solution as an answer.
35,775 reputation · 06 Apr 2020, 20:07 UTC
Omitting NOWAIT makes the Rexx interpreter suspend until the lock is granted. The standard defines no upper bound, retry interval, or query mechanism, so the wait is effectively indefinite and interpreter-dependent.
For backup or restore scripts, use NOWAIT and implement retries in Rexx rather than relying on a platform timeout. Verify behavior by holding a lock in one process and issuing a blocking LOCK in another; observe whether the second process hangs and whether external signals can interrupt it.