tos

package
v0.0.0-...-687e8eb Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 3, 2017 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
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
)
View Source
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
)
View Source
const (
	InvalidPID = -1
)

Variables

This section is empty.

Functions

func Chmod

func Chmod(filePath string, mode os.FileMode) error

Chmod is a wrapper around os.Chmod that allows changing rights recursively if a directory is given.

func Chown

func Chown(filePath string, uid, gid int) error

ChownId is a wrapper around os.Chown that allows changing user and group recursively if given a directory.

func ChownByName

func ChownByName(filePath, usr, grp string) error

ChownByName is a wrapper around ChownId that allows changing user and group by name.

func Copy

func Copy(dest, source string) error

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

func GetFileCredentials(name string) (uid int, gid int, err error)

GetFileCredentials returns the user and group id of a given path. This function is not supported on windows platforms.

func GetFileCredentialsName

func GetFileCredentialsName(name string) (usr string, grp string, err error)

GetFileCredentialsName returns the user and group name of a given path. This function is not supported on windows platforms.

func GetGid

func GetGid(name string) (int, error)

func GetPidFromFile

func GetPidFromFile(filename string) (int, error)

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

func GetProcFromFile(filename string) (*os.Process, error)

GetProcFromFile utilizes GetPidFromFile to create a os.Process handle for the pid contained in the given pid file.

func GetUid

func GetUid(name string) (int, error)
func IsSymlink(file string) (bool, error)

IsSymlink returns true if a file is a symlink

func Terminate

func Terminate(proc *os.Process, gracePeriod time.Duration) error

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

func WritePidFile(pid int, filename string) error

WritePidFile writes this a process id into a file. An error will be returned if the file already exists.

func WritePidFileForced

func WritePidFileForced(pid int, filename string) error

WritePidFileForced writes this a process id into a file. An existing file will be overwritten.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL