diff options
author | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-27 05:58:19 +0000 |
---|---|---|
committer | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-27 05:58:19 +0000 |
commit | 454b3377b8945d39ee501f1a804322fee43c4144 (patch) | |
tree | 836af6da3ccf2a80eb25d48ef328e27bda67a05f /remoting | |
parent | 3caf4701729bbaa97c1034c92fff0a27c26c2b80 (diff) | |
download | chromium_src-454b3377b8945d39ee501f1a804322fee43c4144.zip chromium_src-454b3377b8945d39ee501f1a804322fee43c4144.tar.gz chromium_src-454b3377b8945d39ee501f1a804322fee43c4144.tar.bz2 |
Add timout for the stop command in the chromoting init script.
Remoting host shutdown may timeout in some environment (e.g. when
home directories are on NFS). Ignore this error.
BUG=153090
Review URL: https://chromiumcodereview.appspot.com/11313015
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@164510 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting')
-rwxr-xr-x | remoting/host/installer/linux/debian/chrome-remote-desktop.init | 19 |
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 $? } |