// GetPidFromFile tries loads the content of a pid file.
// A pidfile is expected to contain only an integer with a valid process id.
GetPidFromFile tries loads the content of a pid file.
A pidfile is expected to contain only an integer with a valid process id.
// GetPidFromFile tries loads the content of a pid file . // A pidfile is expected to contain only an integer with a valid process id .
func GetPidFromFile(filename string) (int, error) {
	var (
		pidBytes []byte
		pid      int
		err      error
	)
	if pidBytes, err = ioutil.ReadFile(filename); err != nil {
		return InvalidPID, fmt.Errorf("Could not read pidfile %s: %s", filename, err)
	}
	pidString := string(bytes.Trim(pidBytes, "\r\n\t "))
	if pid, err = strconv.Atoi(string(pidString)); err != nil {
		return InvalidPID, fmt.Errorf("Could not read pid from pidfile %s: %s", filename, err)
	}
	return pid, nil
}
func GetPidFromFile ( filename string ) ( int , error ) { var ( pidBytes [ ] byte pid int err error ) if pidBytes , err = ioutil . ReadFile ( filename ) ; err != nil { return InvalidPID , fmt . Errorf ( " " , filename , err ) } pidString := string ( bytes . Trim ( pidBytes , " \r \n \t " ) ) if pid , err = strconv . Atoi ( string ( pidString ) ) ; err != nil { return InvalidPID , fmt . Errorf ( " " , filename , err ) } return pid , nil }
GetPidFromFile tries loads the content of a pid file.
GetPidFromFile tries loads the content of a pid file .