On Sat, Jun 29, 2024 at 2:07 PM Oğuz <oguzismailuy...@gmail.com> wrote: > > There is a limit to the number of jobs Bash can remember, once it's exceeded > the oldest job is overwritten. Do we really want process substitutions to > count against that limit?
They might already. Now I'm wondering if the documentation just needed updating. I'm afraid to report this as a bug, because it feels like something that running bash in MSYS2 on Windows could be responsible for, but here goes. Configuration Information [Automatically generated, do not change]: Machine: x86_64 OS: msys Compiler: gcc Compilation CFLAGS: -march=nocona -msahf -mtune=generic -O2 -pipe -D_STATIC_BUILD uname output: MINGW64_NT-10.0-19045 Zack2021HPPavilion 3.5.3.x86_64 2024-06-03 06:22 UTC x86_64 Msys Machine Type: x86_64-pc-msys Bash Version: 5.2 Patch Level: 26 Release Status: release Description: So bash can wait on process substitutions. 1) When all child processes are process substitutions: a. wait without arguments actually appears to wait for all of them, not just the last-executed one, contradicting the man page. b. A subsequent call to wait listing all child process pids immediately terminates successfully. c. If calling wait -n in the middle of all this, whether listing only un-waited-on child process pids or all child process pids, it lists all argument pids as "no such job" and terminates with code 127. This is probably incorrect behavior. 2) When a standard background process is added: a. wait without arguments waits for all child processes. b. A subsequent call to wait listing all child process pids lists all argument pids as not children of the shell and terminates with code 127. This seems incorrect, or at least the change in behavior from 1b. is unexpected. c. If calling wait -n in the middle of all this, we see that it only lists the pids from process substitutions as "no such job". Repeat-By: ./procsub-wait false false ./procsub-wait false true ./procsub-wait true false ./procsub-wait true true procsub-wait and the results of running it on the listed system are attached.
zsant@Zack2021HPPavilion MINGW64 ~/random $ ./procsub-wait false false + add_background_process=false + try_wait_n=false + pid=() + declare -a pid + : /dev/fd/63 + pid+=(${!}) ++ sleep 4 + : /dev/fd/63 + pid+=(${!}) ++ sleep 6 + : /dev/fd/63 + pid+=(${!}) ++ sleep 8 + : /dev/fd/63 + pid+=(${!}) + [[ false == \t\r\u\e ]] ++ sleep 10 + : /dev/fd/63 + pid+=(${!}) + SECONDS=0 + declare -p pid declare -a pid=([0]="4004" [1]="4005" [2]="4006" [3]="4007" [4]="4008") + wait -- 4004 ++ sleep 2 + : 'termination status 0 at 4 seconds' + [[ false == \t\r\u\e ]] + wait + : 'termination status 0 at 10 seconds' + wait -- 4004 4005 4006 4007 4008 + : 'termination status 0 at 10 seconds' zsant@Zack2021HPPavilion MINGW64 ~/random $ ./procsub-wait false true + add_background_process=false + try_wait_n=true + pid=() + declare -a pid + : /dev/fd/63 ++ sleep 4 + pid+=(${!}) + : /dev/fd/63 + pid+=(${!}) ++ sleep 6 + : /dev/fd/63 + pid+=(${!}) ++ sleep 8 + : /dev/fd/63 + pid+=(${!}) ++ sleep 10 + [[ false == \t\r\u\e ]] + : /dev/fd/63 + pid+=(${!}) ++ sleep 2 + SECONDS=0 + declare -p pid declare -a pid=([0]="4010" [1]="4011" [2]="4012" [3]="4013" [4]="4014") + wait -- 4010 + : 'termination status 0 at 4 seconds' + [[ true == \t\r\u\e ]] + wait -n -p completed_pid -- 4010 4011 4012 4013 4014 ./procsub-wait: line 22: wait: 4010: no such job ./procsub-wait: line 22: wait: 4011: no such job ./procsub-wait: line 22: wait: 4012: no such job ./procsub-wait: line 22: wait: 4013: no such job ./procsub-wait: line 22: wait: 4014: no such job + : 'termination status 127 at 4 seconds' + declare -p completed_pid ./procsub-wait: line 24: declare: completed_pid: not found + wait + : 'termination status 0 at 10 seconds' + wait -- 4010 4011 4012 4013 4014 + : 'termination status 0 at 10 seconds' zsant@Zack2021HPPavilion MINGW64 ~/random $ ./procsub-wait true false + add_background_process=true + try_wait_n=false + pid=() + declare -a pid + : /dev/fd/63 + pid+=(${!}) ++ sleep 4 + : /dev/fd/63 + pid+=(${!}) ++ sleep 6 + : /dev/fd/63 + pid+=(${!}) ++ sleep 8 + : /dev/fd/63 + pid+=(${!}) + [[ true == \t\r\u\e ]] ++ sleep 10 + pid+=(${!}) + sleep 1 + : /dev/fd/63 + pid+=(${!}) + SECONDS=0 + declare -p pid declare -a pid=([0]="4016" [1]="4017" [2]="4018" [3]="4019" [4]="4020" [5]="4021") + wait -- 4016 ++ sleep 2 + : 'termination status 0 at 4 seconds' + [[ false == \t\r\u\e ]] + wait + : 'termination status 0 at 10 seconds' + wait -- 4016 4017 4018 4019 4020 4021 ./procsub-wait: line 28: wait: pid 4016 is not a child of this shell ./procsub-wait: line 28: wait: pid 4017 is not a child of this shell ./procsub-wait: line 28: wait: pid 4018 is not a child of this shell ./procsub-wait: line 28: wait: pid 4019 is not a child of this shell ./procsub-wait: line 28: wait: pid 4020 is not a child of this shell ./procsub-wait: line 28: wait: pid 4021 is not a child of this shell + : 'termination status 127 at 10 seconds' zsant@Zack2021HPPavilion MINGW64 ~/random $ ./procsub-wait true true + add_background_process=true + try_wait_n=true + pid=() + declare -a pid + : /dev/fd/63 + pid+=(${!}) ++ sleep 4 + : /dev/fd/63 + pid+=(${!}) ++ sleep 6 + : /dev/fd/63 + pid+=(${!}) ++ sleep 8 + : /dev/fd/63 + pid+=(${!}) ++ sleep 10 + [[ true == \t\r\u\e ]] + pid+=(${!}) + sleep 1 + : /dev/fd/63 + pid+=(${!}) ++ sleep 2 + SECONDS=0 + declare -p pid declare -a pid=([0]="4023" [1]="4024" [2]="4025" [3]="4026" [4]="4027" [5]="4028") + wait -- 4023 + : 'termination status 0 at 4 seconds' + [[ true == \t\r\u\e ]] + wait -n -p completed_pid -- 4023 4024 4025 4026 4027 4028 ./procsub-wait: line 22: wait: 4023: no such job ./procsub-wait: line 22: wait: 4024: no such job ./procsub-wait: line 22: wait: 4025: no such job ./procsub-wait: line 22: wait: 4026: no such job ./procsub-wait: line 22: wait: 4028: no such job + : 'termination status 0 at 4 seconds' + declare -p completed_pid declare -- completed_pid="4027" + wait + : 'termination status 0 at 10 seconds' + wait -- 4023 4024 4025 4026 4027 4028 ./procsub-wait: line 28: wait: pid 4023 is not a child of this shell ./procsub-wait: line 28: wait: pid 4024 is not a child of this shell ./procsub-wait: line 28: wait: pid 4025 is not a child of this shell ./procsub-wait: line 28: wait: pid 4026 is not a child of this shell ./procsub-wait: line 28: wait: pid 4027 is not a child of this shell ./procsub-wait: line 28: wait: pid 4028 is not a child of this shell + : 'termination status 127 at 10 seconds'
procsub-wait
Description: Binary data