summaryrefslogtreecommitdiff
path: root/util/flash_ec
diff options
context:
space:
mode:
Diffstat (limited to 'util/flash_ec')
-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