code: func (a *Agent) storePid() error {
  	// Quit fast if no pidfile
  	pidPath := a.config.PidFile
  	if pidPath == "" {
  		return nil
  	}
  
  	// Open the PID file
  	pidFile, err := os.OpenFile(pidPath, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0666)
  	if err != nil {
  		return fmt.Errorf("Could not open pid file: %v", err)
  	}
  	defer pidFile.Close()
  
  	// Write out the PID
  	pid := os.Getpid()
  	_, err = pidFile.WriteString(fmt.Sprintf("%d", pid))
  	if err != nil {
  		return fmt.Errorf("Could not write to pid file: %s", err)
  	}
  	return nil
  }
docs: // storePid is used to write out our PID to a file if necessary