Re: wait inside subshell waits for sibling

2022-10-27 Thread Chet Ramey
On 10/24/22 4:52 AM, Emanuele Torre wrote: On 24/10/2022, Robert Elz wrote: There's no reason that wait (the command) cannot check for candidate jobs which are still running, and wait for any of those, and then return as soon as there are none left. That the shell happens to have forked oth

Re: wait inside subshell waits for sibling

2022-10-27 Thread Chet Ramey
On 10/23/22 10:25 PM, Emanuele Torre wrote: I don't think the process running `cat' is a sibling of the subshell. It's not, but in this case it doesn't matter. `wait' without arguments should wait for the last process substitution only if it's the same as $!. You can wait for other process subs

Re: wait inside subshell waits for sibling

2022-10-27 Thread Oğuz
27 Ekim 2022 Perşembe tarihinde Chet Ramey yazdı: > > Yep, this is a problem. I'll have a fix in the next devel branch push. > Thanks -- Oğuz

Re: wait inside subshell waits for sibling

2022-10-27 Thread Chet Ramey
On 10/23/22 3:47 AM, Oğuz İsmail Uysal wrote: To reproduce:    $ echo $BASH_VERSION    5.2.2(3)-release    $ ( : & wait ) > >(cat)    *hangs* It should return immediately, but hangs instead. Yep, this is a problem. I'll have a fix in the next devel branch push. -- ``The lyf so short, the

Re: wait inside subshell waits for sibling

2022-10-24 Thread Robert Elz
Date:Mon, 24 Oct 2022 16:16:21 +0200 From:Emanuele Torre Message-ID: | It does not make any sense that you keep insisting that this is about | bash internals, or low level system call (especially `wait', `fork', | etc), Since that is the exact opposite of wha

Re: wait inside subshell waits for sibling

2022-10-24 Thread Emanuele Torre
On 24/10/2022, Robert Elz wrote: > | The problem that was described is caused by that > | optimisation (not the version that is applied to simple commands that > | run external program, but to subshell compound command as mentioned). > > I understand that. > > | In case you did not underst

Re: wait inside subshell waits for sibling

2022-10-24 Thread Robert Elz
Date:Mon, 24 Oct 2022 10:52:22 +0200 From:Emanuele Torre Message-ID: | I don't see how this is relevant. See below. | Process substitutions are considered background jobs, and the wait | builtin waits for them. That's fine. | > That is an entirely differ

Re: wait inside subshell waits for sibling

2022-10-24 Thread Emanuele Torre
On 24/10/2022, Robert Elz wrote: > It need not make a difference. The wait command is not intended to > be just the wait(2) (or wait(3) whichever it is on the system in > question) system call (or wrapper around another system call). I don't see how this is relevant. > There's no reason that w

Re: wait inside subshell waits for sibling

2022-10-24 Thread Oğuz
24 Ekim 2022 Pazartesi tarihinde Robert Elz yazdı: > [...] That the shell happens to > have forked other processes for its own reasons should make no > difference at all. Agreed. In the case of process substitutions it is documented that their use may change wait's behavior > If id is not > g

Re: wait inside subshell waits for sibling

2022-10-23 Thread Robert Elz
Date:Mon, 24 Oct 2022 04:25:44 +0200 From:Emanuele Torre Message-ID: | bash performs an optimisation that runs redirections applied to simple | commands that run external programs, or subshell compound commands after | the fork(). (to avoid having to restore f

Re: wait inside subshell waits for sibling

2022-10-23 Thread Oğuz
24 Ekim 2022 Pazartesi tarihinde Emanuele Torre yazdı: > > To inhibit this optimisation, you can wrap your subshell compound > command (or simple command) in a group command, and apply the > redirections to it instead of the subshell command: > > { (: & wait) ;} > >(cat) > > Or, in your specif

Re: wait inside subshell waits for sibling

2022-10-23 Thread Emanuele Torre
I don't think the process running `cat' is a sibling of the subshell. bash performs an optimisation that runs redirections applied to simple commands that run external programs, or subshell compound commands after the fork(). (to avoid having to restore file descriptors after running the command.)