On Mon, Mar 11, 2024 at 07:22:39PM +0100, Mischa Baars wrote:
> On Mon, Mar 11, 2024 at 6:22 PM alex xmb sw ratchev <[email protected]>
> wrote:
>
> > i also completly dont get ur issue
> >
> > f=( a.c b.c .. ) threads=$( nproc ) i=-1 r=
> >
> > while [[ -v f[++i] ]] ; do
> > (( ++r > threads )) &&
> > wait -n
> > gcc -c "${f[i]}" &
> > done
> >
>
> How nice!
>
> wait -n exit 1 & echo $?
>
> You got me the solution :) Except that wait expects a pid after -n.
No, wait -n without a PID waits for any one job to complete.
hobbit:~$ sleep 123 & sleep 234 & sleep 3 & wait -n
[1] 513337
[2] 513338
[3] 513339
[3]+ Done sleep 3
hobbit:~$ ps
PID TTY TIME CMD
1138 pts/0 00:00:00 bash
513337 pts/0 00:00:00 sleep
513338 pts/0 00:00:00 sleep
513341 pts/0 00:00:00 ps
hobbit:~$