suppose I want to run a few (say, three) programs at once, like this

```
program1 & program2 & program3 &

```

if I want to know their `pid's`, I think the best way is to store them, like this

```
program1 &
pid1=$!
program2 &
pid2=$!
...

```

But now, what if I want to know if they have ended and if so, what value they returned? Something like this:

```
if [ program1 has ended ]; then
    do something with its return value
fi

```

Any help will be appreciated