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>
This commit is contained in:
Doug Anderson
2014-03-20 14:12:12 -07:00
committed by chrome-internal-fetch
parent eaa645e0cc
commit 39194d5fc5

View File

@@ -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