Sha256: 55763622f8e1b14f64bdedfbd5fea7bb3156abc1f8edce79821ace9d4786b59e
Contents?: true
Size: 621 Bytes
Versions: 6
Compression:
Stored size: 621 Bytes
Contents
#!/usr/bin/env bash script_status="running" # Start the program in the background exec "$@" & pid1=$! shutdown(){ local pid1=$1 local pid2=$2 if [ $script_status = "running" ]; then script_status="shutting down" wait "$pid1" ret=$? kill -KILL "$pid2" exit $ret fi } # Silence warnings from here on exec >/dev/null 2>&1 # Read from stdin in the background and # kill running program when stdin closes exec 0<&0 "$( while read -r; do :; done kill -KILL "$pid1" )" & pid2=$! # Clean up trap 'shutdown $pid1 $pid2' INT HUP TERM shutdown "$pid1" "$pid2"
Version data entries
6 entries across 6 versions & 1 rubygems