~emersion/mrsh

ref: ec97ac337f6321197c3809759b75eeda97e1bdc9 mrsh/test/async.sh -rw-r--r-- 449 bytes
ec97ac33Simon Ser shell/task/word: implement trim prefix/suffix operator for simple patterns 2 years 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.