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

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

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,

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

Re: wait inside subshell waits for sibling

2022-10-24 Thread Emanuele Torre
; | In case you did not understand, the issue is not that "wait inside > | subshell waits for sibling", because the process that runs `cat' IS NOT > | a sibling of the process that runs `wait', it is a CHILD. > > I understand that, but you are missing the point. This is where the

Re: wait inside subshell waits for sibling

2022-10-24 Thread Robert Elz
ommand as mentioned). I understand that. | In case you did not understand, the issue is not that "wait inside | subshell waits for sibling", because the process that runs `cat' IS NOT | a sibling of the process that runs `wait', it is a CHILD. I understand that, but you are m

Re: wait inside subshell waits for sibling

2022-10-24 Thread Emanuele Torre
isn't what some people might expect is irrelevant. What do you mean? 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). In case you did not understand, the issue is

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 >

Re: wait inside subshell waits for sibling

2022-10-24 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

Re: wait inside subshell waits for sibling

2022-10-24 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

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

wait inside subshell waits for sibling

2022-10-23 Thread Oğuz İsmail Uysal
To reproduce: $ echo $BASH_VERSION 5.2.2(3)-release $ ( : & wait ) > >(cat) *hangs* It should return immediately, but hangs instead.