package signal
import "github.com/docker/cli/components/engine/pkg/signal"
Package signal provides helper functions for dealing with signals across various operating systems.
Index ¶
- Constants
- Variables
- func CatchAll(sigc chan os.Signal)
- func DumpStacks(dir string) (string, error)
- func ParseSignal(rawSignal string) (syscall.Signal, error)
- func StopCatch(sigc chan os.Signal)
- func Trap(cleanup func(), logger interface { Info(args ...interface{}) })
- func ValidSignalForPlatform(sig syscall.Signal) bool
Constants ¶
const ( // SIGCHLD is a signal sent to a process when a child process terminates, is interrupted, or resumes after being interrupted. SIGCHLD = syscall.SIGCHLD // SIGWINCH is a signal sent to a process when its controlling terminal changes its size SIGWINCH = syscall.SIGWINCH // SIGPIPE is a signal sent to a process when a pipe is written to before the other end is open for reading SIGPIPE = syscall.SIGPIPE // DefaultStopSignal is the syscall signal used to stop a container in unix systems. DefaultStopSignal = "SIGTERM" )
Variables ¶
var SignalMap = map[string]syscall.Signal{ "ABRT": syscall.SIGABRT, "ALRM": syscall.SIGALRM, "BUG": syscall.SIGBUS, "CHLD": syscall.SIGCHLD, "CONT": syscall.SIGCONT, "EMT": syscall.SIGEMT, "FPE": syscall.SIGFPE, "HUP": syscall.SIGHUP, "ILL": syscall.SIGILL, "INFO": syscall.SIGINFO, "INT": syscall.SIGINT, "IO": syscall.SIGIO, "IOT": syscall.SIGIOT, "KILL": syscall.SIGKILL, "PIPE": syscall.SIGPIPE, "PROF": syscall.SIGPROF, "QUIT": syscall.SIGQUIT, "SEGV": syscall.SIGSEGV, "STOP": syscall.SIGSTOP, "SYS": syscall.SIGSYS, "TERM": syscall.SIGTERM, "TRAP": syscall.SIGTRAP, "TSTP": syscall.SIGTSTP, "TTIN": syscall.SIGTTIN, "TTOU": syscall.SIGTTOU, "URG": syscall.SIGURG, "USR1": syscall.SIGUSR1, "USR2": syscall.SIGUSR2, "VTALRM": syscall.SIGVTALRM, "WINCH": syscall.SIGWINCH, "XCPU": syscall.SIGXCPU, "XFSZ": syscall.SIGXFSZ, }
SignalMap is a map of Darwin signals.
Functions ¶
func CatchAll ¶
CatchAll catches all signals and relays them to the specified channel.
func DumpStacks ¶
DumpStacks appends the runtime stack into file in dir and returns full path to that file.
func ParseSignal ¶
ParseSignal translates a string to a valid syscall signal. It returns an error if the signal map doesn't include the given signal.
func StopCatch ¶
StopCatch stops catching the signals and closes the specified channel.
func Trap ¶
func Trap(cleanup func(), logger interface { Info(args ...interface{}) })
Trap sets up a simplified signal "trap", appropriate for common behavior expected from a vanilla unix command-line tool in general (and the Docker engine in particular).
- If SIGINT or SIGTERM are received, `cleanup` is called, then the process is terminated.
- If SIGINT or SIGTERM are received 3 times before cleanup is complete, then cleanup is skipped and the process is terminated immediately (allows force quit of stuck daemon)
- A SIGQUIT always causes an exit without cleanup, with a goroutine dump preceding exit.
- Ignore SIGPIPE events. These are generated by systemd when journald is restarted while the docker daemon is not restarted and also running under systemd. Fixes https://github.com/docker/docker/issues/19728
func ValidSignalForPlatform ¶
ValidSignalForPlatform returns true if a signal is valid on the platform
Source Files ¶
signal.go signal_darwin.go signal_unix.go trap.go
Directories ¶
Path | Synopsis |
---|---|
components/engine/pkg/signal/testfiles |
- Version
- v17.10.0-ce-rc1+incompatible
- Published
- Oct 4, 2017
- Platform
- darwin/amd64
- Imports
- 11 packages
- Last checked
- 4 seconds ago –
Tools for package owners.