mirror of
https://github.com/lloeki/toolbelt.git
synced 2025-12-06 01:54:41 +01:00
22 lines
303 B
Bash
Executable file
22 lines
303 B
Bash
Executable file
#!/bin/sh
|
|
|
|
# $0 [OPTION] DURATION COMMAND [ARG]...
|
|
# DURATION with suffix: s, m, h, d
|
|
# -k --kill--after
|
|
# -s --signal
|
|
# exit: 124
|
|
|
|
set -e
|
|
set -o nounset
|
|
|
|
wrapper_pid=$$
|
|
seconds="$1"
|
|
shift
|
|
signal='TERM'
|
|
|
|
(sleep $seconds; kill $wrapper_pid) &
|
|
watchdog_pid=$!
|
|
|
|
trap "kill -$signal $watchdog_pid" EXIT
|
|
|
|
$@
|