check_ethernet: hold /run/autotest_pause_ethernet_hook for script duration

Locks aren't sufficient if only one side actually acquires them. Let's
acquire the lock for the duration of the script.

We also shouldn't be removing the lock file unless we really think it's
held by a hung task. Test jobs can handle updating the file modification

Also, update /var/lock to /run/lock. /run/lock is bind-mounted to
/var/lock, so these are the same, but it's nice to use the same path
name. See also

Quirky shell note: POSIX only specifies fd redirection for single-digit
numbers, so '9' is the highest number I can use for 'exec 9>>${FOO}'.
This would be a little nicer if I could use bash...

TEST=power_SuspendStress, see check_ethernet abort
TEST=manual, don't find check_ethernet running 'ping' tests, etc., while
     we hold the lock:
     `while :; do
       touch /run/autotest_pause_ethernet_hook
       flock /run/autotest_pause_ethernet_hook pgrep -l ping
       sleep 1

Cq-Depend: chromium:1637852
Change-Id: I07274519a72fb47fc5d64038649586c7d2b6a819
Commit-Ready: Brian Norris <>
Tested-by: Brian Norris <>
Legacy-Commit-Queue: Commit Bot <>
Reviewed-by: Grant Grundler <>
1 file changed