From 18594a87ba4095e60ec2838610f82b31b73632fd Mon Sep 17 00:00:00 2001 From: Taylor Hutt Date: Thu, 28 Jul 2011 11:45:50 -0700 Subject: [PATCH] chromium-os:17680 : Establish Syncer PID file invariants Details This change updates the use of '-s' to have the proper polarity to see if the syncer PID file is zero bytes in size. As a bit of other cleanup, if a file of size zero is found, it's removed. This allows the second size test of the syncer PID file to be removed. Testing o Created zero-length PID file: saw warning message on console. Saw that the file contains a valid pin while the chroot is entered, and verified the PID file is deleted after exiting chroot. INFO : You may have suffered from chromium-os:17680 and INFO : could have stray 'enter_chroot.sh' processes running. INFO : Erroneous PID file will be cleaned up. o Entered chroot with multiple terminals, saw that the PID file is removed & the syncer process is killed when the last client exits the chroot. o Executed './enter_chroot.sh --verbose', changed ownership of PID file to 'root'. Exited and did not see the following diagnostic message: INFO : Unable to clean up syncer process. The message should not be printed because the file is removed under 'sudo'. BUG=chromium-os:17680 TEST=See above. Signed-off-by: Taylor Hutt Change-Id: I055fe72b9322acee8c774401b3452ef502b30970 Reviewed-on: http://gerrit.chromium.org/gerrit/4936 Tested-by: Taylor Hutt Reviewed-by: David James --- enter_chroot.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/enter_chroot.sh b/enter_chroot.sh index 14ef354004..1f2039749f 100755 --- a/enter_chroot.sh +++ b/enter_chroot.sh @@ -217,15 +217,15 @@ function setup_env { # restart. # # The daemon is killed by the enter_chroot that exits last. - if [ -f "${SYNCERPIDFILE}" ] && [ -s "${SYNCERPIDFILE}" ] ; then + if [ -f "${SYNCERPIDFILE}" ] && [ ! -s "${SYNCERPIDFILE}" ] ; then info "You may have suffered from chromium-os:17680 and"; info "could have stray 'enter_chroot.sh' processes running."; info "You must manually kill any such stray processes."; info "Exit all chroot shells; remaining 'enter_chroot.sh'"; info "processes are probably stray."; + sudo rm -f "${SYNCERPIDFILE}"; fi; if ! [ -f "${SYNCERPIDFILE}" ] || \ - [ -s "${SYNCERPIDFILE}" ] || \ ! [ -d /proc/$(cat "${SYNCERPIDFILE}") ]; then debug "Starting sync process" env_sync_proc & @@ -387,7 +387,7 @@ function teardown_env { # starting the syncer process when this occurs by deleting the # PID file. kill $(cat "${SYNCERPIDFILE}") && \ - rm -f "${SYNCERPIDFILE}" || \ + sudo rm -f "${SYNCERPIDFILE}" || \ debug "Unable to clean up syncer process."; MOUNTED_PATH=$(readlink -f "$FLAGS_chroot")