summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDoug Anderson <dianders@chromium.org>2014-03-20 14:12:12 -0700
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2014-04-11 04:01:06 +0000
commit39194d5fc584199fad690939b362e61b1aa4a12d (patch)
tree463435286ac552416ed17a863de7000d402aa4d4
parenteaa645e0cc092fbaaa1a81ed5308831e71ebf86c (diff)
downloadchrome-ec-39194d5fc584199fad690939b362e61b1aa4a12d.tar.gz
flash_ec: Only kill -9 as a last resort
When we use 'kill -9' to kill other users of the serial port then we end up with stale lockfile warnings. Try to use a normal kill first to be a little nicer. BRANCH=ToT BUG=None TEST=flash_ec and no longer get stale lockfile messages from cu. Change-Id: Idb39ca803a9c54b6fe972f6854515ea5a8bdab03 Signed-off-by: Doug Anderson <dianders@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/194190 Reviewed-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
-rwxr-xr-xutil/flash_ec23
1 files changed, 20 insertions, 3 deletions
diff --git a/util/flash_ec b/util/flash_ec
index 34ee8b4ea8..b016cae3d7 100755
--- a/util/flash_ec
+++ b/util/flash_ec
@@ -135,11 +135,28 @@ function servo_restore() {
}
function free_pty() {
+ local pids
+
pids=$(lsof -F p 2>/dev/null -- $1 | cut -d'p' -f2)
- if [ "${pids}" != "" ]; then
- kill -9 ${pids}
- info "You'll need to re-launch console on $1"
+ if [ "${pids}" == "" ]; then
+ return
fi
+
+ # Try to kill nicely at first...
+ kill ${pids}
+ info "You'll need to re-launch console on $1"
+
+ # Wait up to 3 seconds for them to die...
+ for i in $(seq 30); do
+ pids=$(lsof -F p 2>/dev/null -- $1 | cut -d'p' -f2)
+ if [ "${pids}" == "" ]; then
+ return
+ fi
+ sleep .1
+ done
+
+ # Forcibly kill
+ kill -9 ${pids}
}
# Board specific flashing scripts