From 470be99f4f6841517ade9233dc020535d7b19f20 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Wed, 28 Sep 2011 11:53:56 -0400 Subject: [PATCH] enter_chroot: try to avoid sudo when deleting sync pid file The sync pid file is created without using sudo which means we should be able to delete it without using sudo. By default, run `rm` directly and if it fails, fall back to sudo like we historically have. BUG=None TEST=`cros_sdk --enter true`; see pid file deleted Change-Id: I26d898f6d594eb9ea4652335468345dd11303122 Reviewed-on: http://gerrit.chromium.org/gerrit/8644 Commit-Ready: Mike Frysinger Reviewed-by: Mike Frysinger Tested-by: Mike Frysinger --- sdk_lib/enter_chroot.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sdk_lib/enter_chroot.sh b/sdk_lib/enter_chroot.sh index a017285b51..3d7582f5a4 100755 --- a/sdk_lib/enter_chroot.sh +++ b/sdk_lib/enter_chroot.sh @@ -418,8 +418,9 @@ function teardown_env { # starting the syncer process when this occurs by deleting the # PID file. kill $(<"${SYNCERPIDFILE}") && \ - sudo rm -f "${SYNCERPIDFILE}" || \ - debug "Unable to clean up syncer process."; + { rm -f "${SYNCERPIDFILE}" 2>/dev/null || \ + sudo rm -f "${SYNCERPIDFILE}" ; } || + debug "Unable to clean up syncer process."; debug "Unmounting chroot environment." safe_umount_tree "${MOUNTED_PATH}/"