Only one lxc exec in a shell while loop

For some reason a shell while loop breaks off when doing lxc exec in the loop.

Here is a shell command that stops after one loop iteration.

echo 'does3
kanboard
gulp' | while read h; do lxc exec $h cat /etc/issue; done

A for loop does not have the problem. And any other lxc command (e.g. lxc info) does not have the problem either.

for h in does3 kanboard gulp; do lxc exec $h cat /etc/issue; done

Can any of the shell gurus explain what’s causing this?

BTW. The list of containers is the output of this

lxc list --format json | jq -r '.[] | select(.status == "Running") | .name'

My workaround is to avoid while and doit like this.

for h in $(lxc list --format json | jq -r '.[] | select(.status == "Running") | .name')
do
    echo ">>>> $h"
    lxc exec $h cat /etc/issue | head -1
done

It’s likely something funny going on because of your stdin being busy in the while case.

You may want to try lxc exec $h cat /etc/issue </dev/null, if it’s a stdin issue, this should fix it.

Yes. That’s indeed what is going on.