Documentation ¶
Index ¶
- Constants
- func Chmod(filePath string, mode os.FileMode) error
- func Chown(filePath string, uid, gid int) error
- func ChownByName(filePath, usr, grp string) error
- func Copy(dest, source string) error
- func GetFileCredentials(name string) (uid int, gid int, err error)
- func GetFileCredentialsName(name string) (usr string, grp string, err error)
- func GetGid(name string) (int, error)
- func GetPidFromFile(filename string) (int, error)
- func GetProcFromFile(filename string) (*os.Process, error)
- func GetUid(name string) (int, error)
- func IsSymlink(file string) (bool, error)
- func Terminate(proc *os.Process, gracePeriod time.Duration) error
- func WritePidFile(pid int, filename string) error
- func WritePidFileForced(pid int, filename string) error
Constants ¶
const ( // ExitSuccess should be used if no error occured ExitSuccess = 0 // ExitError should be used in general failure cases ExitError = 1 // ExitNotAllowed should be used if a permission problem occured ExitNotAllowed = 2 // ExitCannotExecute should be used if e.g. a subprocess failed to execute ExitCannotExecute = 126 // ExitNotFound should be used if e.g. a subprocess executable was not found ExitNotFound = 127 // ExitInvalidArgument should be used if argument parsing failed ExitInvalidArgument = 128 // ExitSignal + n should be used if the signal with the number n terminated the process ExitSignal = 128 // ExitSignalInt is shorthand for ExitSignal + syscall.SIGINT ExitSignalHup = ExitSignal + syscall.SIGHUP // ExitSignalInt is shorthand for ExitSignal + syscall.SIGINT ExitSignalInt = ExitSignal + syscall.SIGINT // ExitSignalKill is shorthand for ExitSignal + syscall.SIGKILL ExitSignalKill = ExitSignal + syscall.SIGKILL // ExitSignalTerm is shorthand for ExitSignal + syscall.SIGTERM ExitSignalTerm = ExitSignal + syscall.SIGTERM // ExitSignalPipe is shorthand for ExitSignal + syscall.SIGPIPE ExitSignalPipe = ExitSignal + syscall.SIGPIPE // ExitSignalAlarm is shorthand for ExitSignal + syscall.SIGALRM ExitSignalAlarm = ExitSignal + syscall.SIGALRM // ExitSignalTrap is shorthand for ExitSignal + syscall.SIGTRAP ExitSignalTrap = ExitSignal + syscall.SIGTRAP )
const ( // NobodyUid represents the user id of the user nobody NobodyUid = 0xFFFE // NobodyUid represents the group id of the group nobody NobodyGid = 0xFFFE // RootUid represents the user id of the root user RootUid = 0 // RootUid represents the group id of the root group RootGid = 0 )
const (
InvalidPID = -1
)
Variables ¶
This section is empty.
Functions ¶
func Chmod ¶
Chmod is a wrapper around os.Chmod that allows changing rights recursively if a directory is given.
func Chown ¶
ChownId is a wrapper around os.Chown that allows changing user and group recursively if given a directory.
func ChownByName ¶
ChownByName is a wrapper around ChownId that allows changing user and group by name.
func Copy ¶
Copy is a file copy helper. Files will be copied to their destination, overwriting existing files. Already existing files that are not part of the copy process will not be touched. If source is a directory it is walked recursively. Non-existing folders in dest will be created. Copy returns upon the first error encountered. In-between results will not be rolled back.
func GetFileCredentials ¶
GetFileCredentials returns the user and group id of a given path. This function is not supported on windows platforms.
func GetFileCredentialsName ¶
GetFileCredentialsName returns the user and group name of a given path. This function is not supported on windows platforms.
func GetPidFromFile ¶
GetPidFromFile tries loads the content of a pid file. A pidfile is expected to contain only an integer with a valid process id.
func GetProcFromFile ¶
GetProcFromFile utilizes GetPidFromFile to create a os.Process handle for the pid contained in the given pid file.
func Terminate ¶
Terminate tries to gracefully shutdown a process by sending SIGTERM. If the process does not shut down after (at least) gracePeriod a SIGKILL will be sent. 10 checks will be done during gracePeriod to check if the process is still alive. If a gracePeriod of 0 is passed SIGKILL will be send immediately.
func WritePidFile ¶
WritePidFile writes this a process id into a file. An error will be returned if the file already exists.
func WritePidFileForced ¶
WritePidFileForced writes this a process id into a file. An existing file will be overwritten.
Types ¶
This section is empty.