code: func CreatePidFile(name string, perm os.FileMode) (lock *LockFile, err error) {
  	if lock, err = OpenLockFile(name, perm); err != nil {
  		return
  	}
  	if err = lock.Lock(); err != nil {
  		lock.Remove()
  		return
  	}
  	if err = lock.WritePid(); err != nil {
  		lock.Remove()
  	}
  	return
  }
docs: // CreatePidFile opens the named file, applies exclusive lock and writes
  // current process id to file.