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

const (
	SIGCHLD  = syscall.Signal(0xff)
	SIGWINCH = syscall.Signal(0xff)
	SIGPIPE  = syscall.Signal(0xff)
	// DefaultStopSignal is the syscall signal used to stop a container in windows systems.
	DefaultStopSignal = "15"
)

Signals used in cli/command (no windows equivalent, use invalid signals so they don't get handled)

Variables

var SignalMap = map[string]syscall.Signal{
	"KILL": syscall.SIGKILL,
	"TERM": syscall.SIGTERM,
}

SignalMap is a map of "supported" signals. As per the comment in GOLang's ztypes_windows.go: "More invented values for signals". Windows doesn't really support signals in any way, shape or form that Unix does.

We have these so that docker kill can be used to gracefully (TERM) and forcibly (KILL) terminate a container on Windows.

Functions

func CatchAll

func CatchAll(sigc chan os.Signal)

CatchAll catches all signals and relays them to the specified channel.

func DumpStacks

func DumpStacks(dir string) (string, error)

DumpStacks appends the runtime stack into file in dir and returns full path to that file.

func ParseSignal

func ParseSignal(rawSignal string) (syscall.Signal, error)

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

func StopCatch(sigc chan os.Signal)

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).

func ValidSignalForPlatform

func ValidSignalForPlatform(sig syscall.Signal) bool

ValidSignalForPlatform returns true if a signal is valid on the platform

Source Files

signal.go signal_windows.go trap.go

Directories

PathSynopsis
components/engine/pkg/signal/testfiles
Version
v17.11.0-ce-rc3+incompatible
Published
Nov 8, 2017
Platform
windows/amd64
Imports
11 packages
Last checked
1 hour ago

Tools for package owners.