~emersion/mrsh

ref: f1342b124da2cf87e57f70bd8f1a9c221bca47fe mrsh/test/async.sh -rw-r--r-- 449 bytes View raw
f1342b12Simon Ser shell/task/word: implement parameter minus operator 8 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.