~sircmpwn/mrsh

mrsh/test/async.sh -rw-r--r-- 435 bytes View raw
6770e0deDrew DeVault Add configure script and Makefile 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
#!/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
echo Job 1 exited with status $?
wait $!
echo Job 2 exited with status $?

#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.