2 # test program group handling
4 # Copyright (C) 2011 Free Software Foundation, Inc.
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 . "${srcdir=.}/init.sh"; path_prepend_ ../src
22 # construct a program group hierarchy as follows:
23 # timeout-group - foreground group
24 # group.sh - separate group
25 # timeout.cmd - same group as group.sh
27 # We then send a SIGINT to the "separate group"
28 # to simulate what happens when a Ctrl-C
29 # is sent to the foreground group.
31 setsid true || skip_ "setsid required to control groups"
33 cat > timeout.cmd <<\EOF
35 trap 'touch int.received; exit' INT
43 timeout --foreground 5 ./timeout.cmd&
48 # Start above script in its own group.
49 # We could use timeout for this, but that assumes an implementation.
51 until test -e timeout.running; do sleep .1; done
52 # Simulate a Ctrl-C to the group to test timely exit
53 # Note dash doesn't support signalling groups (a leading -)
56 test -e int.received || fail=1