1 # This program is free software: you can redistribute it and/or modify
2 # it under the terms of the GNU General Public License as published by
3 # the Free Software Foundation, either version 3 of the License, or
4 # (at your option) any later version.
6 # This program is distributed in the hope that it will be useful,
7 # but WITHOUT ANY WARRANTY; without even the implied warranty of
8 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 # GNU General Public License for more details.
11 # You should have received a copy of the GNU General Public License
12 # along with this program. If not, see <http://www.gnu.org/licenses/>.
14 # test out %+, jobs -p, and $! agreement in a subshell first
15 ${THIS_SH} ./jobs1.sub
17 # test out fg/bg failure in a subshell
18 ${THIS_SH} ./jobs2.sub
20 # test out behavior of waiting for background pids -- bug in versions
22 ${THIS_SH} ./jobs3.sub
24 # test out behavior of using job control notation when job control is not
26 ${THIS_SH} ./jobs4.sub
28 # test out wait -n framework
29 ${THIS_SH} ./jobs5.sub
31 # test out wait -f framework
32 ${THIS_SH} ./jobs6.sub
34 ${THIS_SH} ./jobs7.sub
39 # a no-such-job error, since we can use job control notation without job control
42 # make sure we can't fg a job started when job control was not active
46 # make sure the killed processes don't cause a message
50 wait # make sure we reap the processes while stderr is still redirected
61 echo wait-for-background-pids
66 echo async list wait-for-background-pids
70 echo async list wait for child
74 echo wait-when-no-children
77 echo posix jobs output
78 ${THIS_SH} -o posix -c 'sleep 1 & P=$! ; sleep 2; jobs; wait'
84 wait %2 # this should be a no-such-job error
88 echo async list wait-for-job
108 # these next two are error cases
111 fg %2 # this should be a no-such-job error
112 bg %1 # this should be a `bg background job?' error
115 # these may someday mean to start the jobs, but not print the line
116 # describing the status, but for now they are errors
123 # someday this may mean to disown all stopped jobs, but for now it is
127 # this is an error -- the job with the pid that is the value of $! is
128 # retained only until a `wait' is performed
131 # this, however, is an error
134 echo wait-for-non-child
138 exit 1 | exit 2 | exit 3
139 echo $? -- ${PIPESTATUS[@]} -- ${PIPESTATUS[0]} - ${PIPESTATUS[1]} - ${PIPESTATUS[2]}
161 sleep 3 # give time for the shell to get the stop notification
162 echo after kill -STOP
178 echo after kill -s CONT
185 sleep 3 # give time for the shell to get the stop notification
186 echo after kill -STOP, backgrounding %3:
191 # make sure the killed processes don't cause a message
196 kill -n 9 $sleep300pid
198 wait # make sure we reap the processes while stderr is still redirected
205 sleep 2 # give time for the shell to get the stop notification
206 echo after KILL -STOP, foregrounding %1