Bash 5.1 process substitution: immediate descriptor reuse?
0 reputation · 18 May 2023, 19:44 UTC
Goal: Understand descriptor reuse in Bash 5.1 process substitution
The objective is to determine whether file descriptors allocated for process substitution are reused immediately after the substitution completes or only after the script terminates. This impacts long‑running scripts that rely heavily on process substitution, as unreused descriptors can exhaust the system’s descriptor table.
Current uncertainty
While the Bash 5.1 release notes introduce an option to control whether descriptors from process substitution are closed immediately, the manual does not guarantee that the descriptor number will be reused for subsequent substitutions. Different Bash builds exhibit varying behavior, leading to inconsistent resource usage.
Specific questions
- Does Bash 5.1 guarantee that a file descriptor number allocated for a process substitution will be reused immediately after the substitution’s associated process terminates, regardless of the “extdebug” or other shell options?
- Under what conditions (e.g., open file descriptors, background processes, or particular shell options) does Bash delay the reuse of descriptors from process substitution until script exit?
- Is there a documented configuration flag or environment variable that explicitly forces immediate reuse of descriptors for process substitution in Bash 5.1?