summaryrefslogtreecommitdiff
path: root/tests/jobs3.sub
blob: 6efd58b09bd4a6027e00531b8ea4b7a601106b5f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#! /bin/bash
NJOB=8
i=0

while [ $i -lt $NJOB ]
do
    /bin/sh -c "sleep 4; exit 0" &
    rv=$?
    pid=$!
    eval bg_pid_$i=$pid
#    echo $$: Job $i: pid is $pid rv=$rv
    i=$((i + 1))
done



i=0
while [ $i -lt $NJOB ]
do
    eval wpid=\$bg_pid_$i
    echo Waiting for job $i #'('pid $wpid')'
    wait $wpid
    rv=$?
    echo job $i returns $rv
    i=$((i + 1))
done