blob: cd044f156a93f1e09b5b44b798fed2f6fe31bdc0 (
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
|
jobs
echo $?
echo wait-for-pid
sleep 10 &
wait $!
echo wait-errors
wait 1-1
wait -- -4
echo wait-for-background-pids
sleep 5 &
sleep 8 &
wait
echo async list wait-for-background-pids
sleep 5 & sleep 8 &
wait
echo async list wait for child
sleep 5 & echo forked
wait
echo wait-when-no-children
wait
set -m
echo wait-for-job
sleep 5 &
wait %2 # this should be a no-such-job error
echo $?
wait %1
echo async list wait-for-job
sleep 5 & echo forked
wait %1
echo fg-bg 1
sleep 5 &
%1
echo fg-bg 2
sleep 5 &
fg %%
echo fg-bg 3
sleep 5 &
fg %s
echo fg-bg 4
sleep 5 &
fg %?ee
# these next two are error cases
echo fg-bg 5
sleep 15 &
fg %2 # this should be a no-such-job error
bg %1 # this should be a `bg background job?' error
wait
# these may someday mean to start the jobs, but not print the line
# describing the status, but for now they are errors
echo fg-bg 6
sleep 5 &
fg -s %1
bg -s %1
wait
# someday this may mean to disown all running jobs, but for now it is
# an error
disown -r
# this is an error
disown %1
echo wait-for-non-child
wait 1
echo $?
exit 1 | exit 2 | exit 3
echo $? -- ${PIPESTATUS[@]} -- ${PIPESTATUS[0]} - ${PIPESTATUS[1]} - ${PIPESTATUS[2]}
sleep 300 &
sleep 350 &
sleep 400 &
jobs
echo running jobs:
jobs -r
# should be an error
kill -n 1 %4
kill -STOP %2
sleep 5 # give time for the shell to get the stop notification
echo after kill -STOP
echo running jobs:
jobs -r
echo stopped jobs:
jobs -s
disown %1
echo after disown
jobs
echo running jobs:
jobs -r
echo stopped jobs:
jobs -s
kill -s CONT %2
echo after kill -s CONT
echo running jobs:
jobs -r
echo stopped jobs:
jobs -s
kill -STOP %3
sleep 5 # give time for the shell to get the stop notification
echo after kill -STOP, backgrounding %3:
bg %3
disown -h %2
# make sure the killed processes don't cause a message
exec 5>&2
exec 2>/dev/null
echo killing...
kill -n 9 %2 %3
wait # make sure we reap the processes while stderr is still redirected
echo done
exec 2>&5
sleep 10 &
kill -STOP %1
sleep 5 # give time for the shell to get the stop notification
echo after KILL -STOP, foregrounding %1
fg %1
echo done
|