looks like what's happening is that the parent bash process doesn't
invoke the process substitution itself.   Rather, the subprocess that
will exec the command itself *first* spawns a grandchild process for the
process execution, before execing the expected command.

that means that wait(-1) of the expected command is going to hang
because it's waiting on a child process that it doesn't know about.

here's the relevant strace info:

$ strace -T -tt -f -e wait4,clone,execve ./wait-hang-behavior.bash 
14:58:44.997547 execve("./wait-hang-behavior.bash", 
["./wait-hang-behavior.bash"], 0x7ffccd028678 /* 53 vars */) = 0 <0.000508>
14:58:45.006079 clone(strace: Process 12365 attached
child_stack=NULL, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, 
child_tidptr=0x7f6b51955a10) = 12365 <0.000207>
[pid 12364] 14:58:45.006703 wait4(-1,  <unfinished ...>
[pid 12365] 14:58:45.007253 clone(strace: Process 12366 attached
child_stack=NULL, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, 
child_tidptr=0x7f6b51955a10) = 12366 <0.000081>
[pid 12365] 14:58:45.007599 execve("./wait-hang-behavior-2.bash", 
["./wait-hang-behavior-2.bash"], 0x563b2c6c4c50 /* 53 vars */) = 0 <0.000260>
[pid 12366] 14:58:45.008281 clone(strace: Process 12367 attached
child_stack=NULL, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, 
child_tidptr=0x7f6b51955a10) = 12367 <0.000088>
[pid 12366] 14:58:45.008577 wait4(-1,  <unfinished ...>
[pid 12367] 14:58:45.008658 execve("/usr/bin/tee", ["tee", "-p", "./stdout"], 
0x563b2c6c4c50 /* 53 vars */) = 0 <0.000166>
hi there
[pid 12365] 14:58:45.011442 wait4(-1,   C-c C-c <unfinished ...>
[pid 12364] 14:59:04.039138 <... wait4 resumed> 0x7fff384a5340, 0, NULL) = ? 
ERESTARTSYS (To be restarted if SA_RESTART is set) <19.032359>
strace: Process 12364 detached
strace: Process 12365 detached
strace: Process 12366 detached
strace: Process 12367 detached

Attachment: signature.asc
Description: PGP signature

Reply via email to