Chromium Code Reviews| Index: lib/cros_vm_lib.sh |
| diff --git a/lib/cros_vm_lib.sh b/lib/cros_vm_lib.sh |
| index d28539c14d5b068fc3003a6be971c8bf64d29c5c..7f4744e9fb0c2ee53b2aec2b00d733f357c1e755 100644 |
| --- a/lib/cros_vm_lib.sh |
| +++ b/lib/cros_vm_lib.sh |
| @@ -19,6 +19,14 @@ function get_pid() { |
| sudo cat "${KVM_PID_FILE}" |
| } |
| +# General purpose wait for processes that may not be your child. |
| +# $1 the process id. |
| +function wait_on_pid() { |
| + while ps -p ${1} > /dev/null; do |
|
petkov
2010/12/09 22:29:03
do you want to do a local timeout? e.g., give up a
|
| + sleep .5 |
| + done |
| +} |
| + |
| # TODO(rtc): These flags assume that we'll be using KVM on Lucid and won't work |
| # on Hardy. |
| # $1: Path to the virtual image to start. |
| @@ -99,6 +107,7 @@ function stop_kvm() { |
| if [ -n "${pid}" ]; then |
| echo "Killing ${pid}" >&2 |
| sudo kill ${pid} |
| + wait_on_pid ${pid} |
| sudo rm "${KVM_PID_FILE}" |
| else |
| echo "No kvm pid found to stop." >&2 |