chromium-os:17680 : Establish Syncer PID file invariants
chromium-os:17680 : Establish Syncer PID file invariants

Details

  I have a set of scripts which run from outside the chroot; they
  execute things inside the chroot, and therefore enter & exit the
  chroot frequently.

  This morning I noticed this morning that I was getting

    kill: usage: kill [-s sigspec | -n signum | -sigspec] pid | jobspec ... or kill -l [sigspec]

  on the console each time I exited the chroot.

  I tracked this down to the 'sync process' PID file; in my case, it
  was zero bytes in size.

  A little more detective work led to
  412b902b0edeef4f02f6b3548227fc2d25084abb and I think I pieced
  together that I had suffered from chromium-os:17680, which resulted
  in an empty file.

  This change is my attempt at repairing the damage if
  chromium-os:17680 has been hit, and preventing other types of
  similar issues with the PID file.

  412b902b0edeef4f02f6b3548227fc2d25084abb addressed the main cause of
  issue chromium-os:17680, and this change  addresses mysterious
  behavior in chroots that have suffered from it.

  To allow people to know that they've possibly got stray syncer
  porcesses running, I also output a message to the console which
  indicates such.

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 saw the following diagnostic message:

       INFO    : Unable to clean up syncer process.

BUG=chromium-os:17680
TEST=See above
Signed-off-by: Taylor Hutt <39a9c928d8a3a00d7fd484a843cc4ccfc80af42c@chromium.org>

Change-Id: Idf9059509bbc6e0a926efd549922d05b9b742fa0
Signed-off-by: Taylor Hutt <39a9c928d8a3a00d7fd484a843cc4ccfc80af42c@chromium.org>
Reviewed-on: http://gerrit.chromium.org/gerrit/4837

BugRoger/scripts,BugRoger/scripts,sigma/coreos-scripts,zhang0137/scripts,glevand/coreos--scripts,glevand/coreos--scripts,smilart/scripts,vmware/coreos-scripts,trnubo/scripts,BugRoger/scripts,sigma/coreos-scripts,gtank/scripts,trnubo/scripts,mjg59/scripts,bcwaldon/coreos-scripts,smilart/scripts,mischief/scripts,bcwaldon/coreos-scripts,gtank/scripts,crawford/scripts,endocode/scripts,marineam/coreos-scripts,andrejro/coreos--scripts,zhang0137/scripts,endocode/scripts,fivethreeo/scripts,fivethreeo/scripts,gtank/scripts,trnubo/scripts,crawford/scripts,marineam/coreos-scripts,mischief/scripts,sigma/coreos-scripts,mischief/scripts,mjg59/scripts,mjg59/scripts,crawford/scripts,nicescale/scripts,andrejro/coreos--scripts,fivethreeo/scripts,coreos/scripts,vmware/coreos-scripts,bcwaldon/coreos-scripts,zhang0137/scripts,endocode/scripts,nicescale/scripts,smilart/scripts,nicescale/scripts,marineam/coreos-scripts,vmware/coreos-scripts,andrejro/coreos--scripts,coreos/scripts