On Tue, Jul 15, 2025 at 6:52 AM Zachary Santer <zsan...@gmail.com> wrote:
>
> Alright, that's definitely what's going on.

Actually, no. I am having a heck of a time trying to duplicate this
behavior any other way. See attached. This is the current tip of the
devel branch, 80a8f650a1.

It has to be commands executed separately on the command line? Could
that be something about job control messing it up?

On the bright side, John, if you're not running 'wait -n' on the
command line or with PROMPT_COMMAND or something similar, I think
you're good to go.
zsant@Zack2021HPPavilion MSYS ~/repos/bash
$ ./bash ~/random/wait-n-and-procsub run
+ : 'BASH_VERSION=5.3.0(1)-maint'
+ sleep 2
+ : 'pid 485'
+ : /dev/fd/63
++ sleep 3
+ : 'pid 486'
+ : 'pid 487'
+ wait -n -p waited_for -- 487
+ sleep 4
+ : waited_for=487
+ : SECONDS=4
+ set +x

zsant@Zack2021HPPavilion MSYS ~/repos/bash
$ ./bash -i ~/random/wait-n-and-procsub run
+ : 'BASH_VERSION=5.3.0(1)-maint'
+ sleep 2
+ : 'pid 489'
+ : /dev/fd/63
++ sleep 3
+ : 'pid 490'
+ : 'pid 491'
+ wait -n -p waited_for -- 491
+ sleep 4
[2]+  Done                       sleep 4
+ : waited_for=491
+ : SECONDS=4
+ set +x

zsant@Zack2021HPPavilion MSYS ~/repos/bash
$ ./bash

zsant@Zack2021HPPavilion MSYS ~/repos/bash
$ source ~/random/wait-n-and-procsub run
++ : 'BASH_VERSION=5.3.0(1)-maint'
++ sleep 2
++ : 'pid 493'
++ : /dev/fd/63
++ : 'pid 494'
+++ sleep 3
++ : 'pid 495'
++ sleep 4
++ wait -n -p waited_for -- 495
[2]+  Done                       sleep 4
++ : waited_for=495
++ : SECONDS=4
++ set +x
[1]   Done                       sleep 2

zsant@Zack2021HPPavilion MSYS ~/repos/bash
$ exit
exit

zsant@Zack2021HPPavilion MSYS ~/repos/bash
$ ./bash

zsant@Zack2021HPPavilion MSYS ~/repos/bash
$ source ~/random/wait-n-and-procsub

zsant@Zack2021HPPavilion MSYS ~/repos/bash
$ wait_n_test
+ : 'BASH_VERSION=5.3.0(1)-maint'
+ sleep 2
[1] 497
+ : 'pid 497'
+ : /dev/fd/63
+ : 'pid 498'
++ sleep 3
[2] 499
+ : 'pid 499'
+ wait -n -p waited_for -- 499
+ sleep 4
[2]+  Done                       sleep 4
+ : waited_for=499
+ : SECONDS=4
+ set +x
[1]   Done                       sleep 2

zsant@Zack2021HPPavilion MSYS ~/repos/bash
$ exit
exit

zsant@Zack2021HPPavilion MSYS ~/repos/bash
$ ./bash

zsant@Zack2021HPPavilion MSYS ~/repos/bash
$ {
  SECONDS=0
  set -x
  : "BASH_VERSION=${BASH_VERSION}"
  sleep 2 &
  : "pid ${!}"
  : <( sleep 3 )
  : "pid ${!}"
  sleep 4 &
  : "pid ${!}"
  wait -n -p waited_for -- "${!}"
  : "waited_for=${waited_for}"
  : "SECONDS=${SECONDS}"
  set +x
}
+ : 'BASH_VERSION=5.3.0(1)-maint'
+ sleep 2
[1] 501
+ : 'pid 501'
+ : /dev/fd/63
+ : 'pid 502'
++ sleep 3
[2] 503
+ sleep 4
+ : 'pid 503'
+ wait -n -p waited_for -- 503
[2]+  Done                       sleep 4
+ : waited_for=503
+ : SECONDS=4
+ set +x
[1]   Done                       sleep 2

zsant@Zack2021HPPavilion MSYS ~/repos/bash
$ exit
exit

zsant@Zack2021HPPavilion MSYS ~/repos/bash
$ ./bash

zsant@Zack2021HPPavilion MSYS ~/repos/bash
$ SECONDS=0
set -x
: "BASH_VERSION=${BASH_VERSION}"
sleep 2 &
: "pid ${!}"
: <( sleep 3 )
: "pid ${!}"
sleep 4 &
: "pid ${!}"
wait -n -p waited_for -- "${!}"
: "waited_for=${waited_for}"
: "SECONDS=${SECONDS}"
set +x
+ : 'BASH_VERSION=5.3.0(1)-maint'
+ sleep 2
[1] 505
+ : 'pid 505'
+ : /dev/fd/63
++ sleep 3
+ : 'pid 506'
+ sleep 4
[2] 507
+ : 'pid 507'
+ wait -n -p waited_for -- 507
[2]+  Done                       sleep 4
[1]   Done                       sleep 2
+ : waited_for=507
+ : SECONDS=4
+ set +x

Attachment: wait-n-and-procsub
Description: Binary data

Reply via email to