summaryrefslogtreecommitdiffstats
path: root/remoting
diff options
context:
space:
mode:
Diffstat (limited to 'remoting')
-rwxr-xr-xremoting/host/installer/linux/debian/chrome-remote-desktop.init19
1 files changed, 18 insertions, 1 deletions
diff --git a/remoting/host/installer/linux/debian/chrome-remote-desktop.init b/remoting/host/installer/linux/debian/chrome-remote-desktop.init
index ea1f399..2a84a7d 100755
--- a/remoting/host/installer/linux/debian/chrome-remote-desktop.init
+++ b/remoting/host/installer/linux/debian/chrome-remote-desktop.init
@@ -29,6 +29,23 @@ else
USERS=$(whoami)
fi
+# Tries to wait for 10 seconds until specified command exits and then kills it.
+run_with_timeout() {
+ "$@" &
+ pid=$!
+ ((time_left = 10))
+ while ((time_left > 0)); do
+ (kill -0 $pid 2>/dev/null) || return `wait $pid`
+ sleep 1
+ ((time_left -= 1))
+ done
+ (kill -0 $pid 2>/dev/null) || return `wait $pid`
+
+ echo command \"$@\" has timed out >&2
+ kill $pid
+ return 1
+}
+
run_and_ignore_error() {
user=$1
shift
@@ -55,7 +72,7 @@ do_start() {
do_stop() {
log_begin_msg "Stopping Chrome Remote Desktop host for $1..."
- run_and_ignore_error $1 "$HOST_PATH --stop"
+ run_with_timeout run_and_ignore_error $1 "$HOST_PATH --stop"
log_end_msg $?
}