summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2017-05-04 03:10:26 -0400
committerLuke Shumaker <lukeshu@lukeshu.com>2017-05-04 03:28:40 -0400
commiteb58f478221cf4f5972d7bcf66afd23c9374fb6d (patch)
tree5aafcffa12a507cb8632877788f0e78b60a3b385 /src
parent23e22a652e8cd3e09b7e74231a957ab921a6732b (diff)
distcc-tool: use `jobs` instead of trying to track PIDs manually.
The old way fails in weird ways if a process dies early.
Diffstat (limited to 'src')
-rwxr-xr-xsrc/chroot-tools/distcc-tool11
1 files changed, 4 insertions, 7 deletions
diff --git a/src/chroot-tools/distcc-tool b/src/chroot-tools/distcc-tool
index 5e71d51..6b03909 100755
--- a/src/chroot-tools/distcc-tool
+++ b/src/chroot-tools/distcc-tool
@@ -109,7 +109,6 @@ parse_DISTCC_HOSTS() {
local forward_ports=$1
local DISTCC_HOSTS=$2
- local pids=() # child pids
local newhosts=()
local newport=8000 # next port to be used for port forwarding
@@ -163,7 +162,6 @@ parse_DISTCC_HOSTS() {
# set up port forwaring
if $forward_ports; then
socat TCP-LISTEN:${newport},reuseaddr,fork SYSTEM:"$q0 client $HOSTID ${PORT:-3632}" &
- pids+=($!)
fi
# add the forwarded port
@@ -176,14 +174,13 @@ parse_DISTCC_HOSTS() {
esac
done
if $forward_ports; then
- if [[ -z "${pids[*]}" ]]; then
+ if [[ $newport == 8000 ]]; then
# listen on port 8000, but immediatly close, just so that we are
# listening on something
socat TCP-LISTEN:${newport},reuseaddr,fork SYSTEM:true &
- pids+=($!)
fi
- trap "kill -- ${pids[*]}" EXIT
- wait "${pids[@]}"
+ trap "jobs -p | xargs -r kill --" EXIT
+ wait
else
printf '%s\n' "${newhosts[*]}"
fi
@@ -225,7 +222,7 @@ odaemon() {
umask 111
socat UNIX-LISTEN:"$chrootpath/socket",fork SYSTEM:"$q0 server" &
- trap "kill -- $!; rm -f -- $(printf '%q' "$chrootpath/socket")" EXIT
+ trap "jobs -p | xargs -r kill --; rm -f -- $(printf '%q' "$chrootpath/socket")" EXIT
wait
}