~emersion/mrsh

ref: 07e65a3a88e03c6d9e6f1f6ac4a1cfa9a74a9b09 mrsh/test/async.sh -rw-r--r-- 449 bytes
07e65a3aSimon Ser parser/arithm: fix && and || 1 year, 10 months ago
                                                                                
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/sh

echo >&2 "Returns immediately"
(wait)

echo >&2 "Run asynchronous list and wait"
echo a &
wait $!

echo >&2 "Run two asynchronous lists in parallel and wait"
echo a &
p1=$!
echo a &
wait $p1
s1=$?
wait $!
s2=$?
echo Job 1 exited with status $s1
echo Job 2 exited with status $s2

#echo >&2 "Run asynchronous list, kill it and wait"
#sleep 1000 &
#pid=$!
#kill -kill $pid
#wait $pid
#echo $pid was terminated by a SIG$(kill -l $?) signal.