aboutsummaryrefslogtreecommitdiff
path: root/vendor
diff options
context:
space:
mode:
authorValentin Rothberg <rothberg@redhat.com>2020-02-12 11:10:55 +0100
committerValentin Rothberg <rothberg@redhat.com>2020-02-14 15:04:14 +0100
commit85b7374491e842c44bec3ce5ec800794cae10295 (patch)
treec45fa8df8796b3741094f796f56b66e9d4388e60 /vendor
parent156ce5cd7d6f0f1514d263a74ffe3dd42f7c7caf (diff)
downloadpodman-85b7374491e842c44bec3ce5ec800794cae10295.tar.gz
podman-85b7374491e842c44bec3ce5ec800794cae10295.tar.bz2
podman-85b7374491e842c44bec3ce5ec800794cae10295.zip
add pkg/signal
Add pkg/signal to deal with parts of signal processing and translating signals from string to numeric representations. The code has been copied from docker/docker (and attributed with the copyright) but been reduced to only what libpod needs (on Linux). Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
Diffstat (limited to 'vendor')
-rw-r--r--vendor/github.com/docker/docker/pkg/signal/README.md1
-rw-r--r--vendor/github.com/docker/docker/pkg/signal/signal.go54
-rw-r--r--vendor/github.com/docker/docker/pkg/signal/signal_darwin.go41
-rw-r--r--vendor/github.com/docker/docker/pkg/signal/signal_freebsd.go43
-rw-r--r--vendor/github.com/docker/docker/pkg/signal/signal_linux.go83
-rw-r--r--vendor/github.com/docker/docker/pkg/signal/signal_linux_mipsx.go84
-rw-r--r--vendor/github.com/docker/docker/pkg/signal/signal_unix.go21
-rw-r--r--vendor/github.com/docker/docker/pkg/signal/signal_unsupported.go10
-rw-r--r--vendor/github.com/docker/docker/pkg/signal/signal_windows.go26
-rw-r--r--vendor/github.com/docker/docker/pkg/signal/trap.go104
-rw-r--r--vendor/modules.txt1
11 files changed, 0 insertions, 468 deletions
diff --git a/vendor/github.com/docker/docker/pkg/signal/README.md b/vendor/github.com/docker/docker/pkg/signal/README.md
deleted file mode 100644
index 2b237a594..000000000
--- a/vendor/github.com/docker/docker/pkg/signal/README.md
+++ /dev/null
@@ -1 +0,0 @@
-This package provides helper functions for dealing with signals across various operating systems \ No newline at end of file
diff --git a/vendor/github.com/docker/docker/pkg/signal/signal.go b/vendor/github.com/docker/docker/pkg/signal/signal.go
deleted file mode 100644
index 88ef7b5ea..000000000
--- a/vendor/github.com/docker/docker/pkg/signal/signal.go
+++ /dev/null
@@ -1,54 +0,0 @@
-// Package signal provides helper functions for dealing with signals across
-// various operating systems.
-package signal // import "github.com/docker/docker/pkg/signal"
-
-import (
- "fmt"
- "os"
- "os/signal"
- "strconv"
- "strings"
- "syscall"
-)
-
-// CatchAll catches all signals and relays them to the specified channel.
-func CatchAll(sigc chan os.Signal) {
- var handledSigs []os.Signal
- for _, s := range SignalMap {
- handledSigs = append(handledSigs, s)
- }
- signal.Notify(sigc, handledSigs...)
-}
-
-// StopCatch stops catching the signals and closes the specified channel.
-func StopCatch(sigc chan os.Signal) {
- signal.Stop(sigc)
- close(sigc)
-}
-
-// ParseSignal translates a string to a valid syscall signal.
-// It returns an error if the signal map doesn't include the given signal.
-func ParseSignal(rawSignal string) (syscall.Signal, error) {
- s, err := strconv.Atoi(rawSignal)
- if err == nil {
- if s == 0 {
- return -1, fmt.Errorf("Invalid signal: %s", rawSignal)
- }
- return syscall.Signal(s), nil
- }
- signal, ok := SignalMap[strings.TrimPrefix(strings.ToUpper(rawSignal), "SIG")]
- if !ok {
- return -1, fmt.Errorf("Invalid signal: %s", rawSignal)
- }
- return signal, nil
-}
-
-// ValidSignalForPlatform returns true if a signal is valid on the platform
-func ValidSignalForPlatform(sig syscall.Signal) bool {
- for _, v := range SignalMap {
- if v == sig {
- return true
- }
- }
- return false
-}
diff --git a/vendor/github.com/docker/docker/pkg/signal/signal_darwin.go b/vendor/github.com/docker/docker/pkg/signal/signal_darwin.go
deleted file mode 100644
index ee5501e3d..000000000
--- a/vendor/github.com/docker/docker/pkg/signal/signal_darwin.go
+++ /dev/null
@@ -1,41 +0,0 @@
-package signal // import "github.com/docker/docker/pkg/signal"
-
-import (
- "syscall"
-)
-
-// SignalMap is a map of Darwin signals.
-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,
-}
diff --git a/vendor/github.com/docker/docker/pkg/signal/signal_freebsd.go b/vendor/github.com/docker/docker/pkg/signal/signal_freebsd.go
deleted file mode 100644
index 764f90e26..000000000
--- a/vendor/github.com/docker/docker/pkg/signal/signal_freebsd.go
+++ /dev/null
@@ -1,43 +0,0 @@
-package signal // import "github.com/docker/docker/pkg/signal"
-
-import (
- "syscall"
-)
-
-// SignalMap is a map of FreeBSD signals.
-var SignalMap = map[string]syscall.Signal{
- "ABRT": syscall.SIGABRT,
- "ALRM": syscall.SIGALRM,
- "BUF": 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,
- "LWP": syscall.SIGLWP,
- "PIPE": syscall.SIGPIPE,
- "PROF": syscall.SIGPROF,
- "QUIT": syscall.SIGQUIT,
- "SEGV": syscall.SIGSEGV,
- "STOP": syscall.SIGSTOP,
- "SYS": syscall.SIGSYS,
- "TERM": syscall.SIGTERM,
- "THR": syscall.SIGTHR,
- "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,
-}
diff --git a/vendor/github.com/docker/docker/pkg/signal/signal_linux.go b/vendor/github.com/docker/docker/pkg/signal/signal_linux.go
deleted file mode 100644
index 4013bded1..000000000
--- a/vendor/github.com/docker/docker/pkg/signal/signal_linux.go
+++ /dev/null
@@ -1,83 +0,0 @@
-// +build !mips,!mipsle,!mips64,!mips64le
-
-package signal // import "github.com/docker/docker/pkg/signal"
-
-import (
- "syscall"
-
- "golang.org/x/sys/unix"
-)
-
-const (
- sigrtmin = 34
- sigrtmax = 64
-)
-
-// SignalMap is a map of Linux signals.
-var SignalMap = map[string]syscall.Signal{
- "ABRT": unix.SIGABRT,
- "ALRM": unix.SIGALRM,
- "BUS": unix.SIGBUS,
- "CHLD": unix.SIGCHLD,
- "CLD": unix.SIGCLD,
- "CONT": unix.SIGCONT,
- "FPE": unix.SIGFPE,
- "HUP": unix.SIGHUP,
- "ILL": unix.SIGILL,
- "INT": unix.SIGINT,
- "IO": unix.SIGIO,
- "IOT": unix.SIGIOT,
- "KILL": unix.SIGKILL,
- "PIPE": unix.SIGPIPE,
- "POLL": unix.SIGPOLL,
- "PROF": unix.SIGPROF,
- "PWR": unix.SIGPWR,
- "QUIT": unix.SIGQUIT,
- "SEGV": unix.SIGSEGV,
- "STKFLT": unix.SIGSTKFLT,
- "STOP": unix.SIGSTOP,
- "SYS": unix.SIGSYS,
- "TERM": unix.SIGTERM,
- "TRAP": unix.SIGTRAP,
- "TSTP": unix.SIGTSTP,
- "TTIN": unix.SIGTTIN,
- "TTOU": unix.SIGTTOU,
- "URG": unix.SIGURG,
- "USR1": unix.SIGUSR1,
- "USR2": unix.SIGUSR2,
- "VTALRM": unix.SIGVTALRM,
- "WINCH": unix.SIGWINCH,
- "XCPU": unix.SIGXCPU,
- "XFSZ": unix.SIGXFSZ,
- "RTMIN": sigrtmin,
- "RTMIN+1": sigrtmin + 1,
- "RTMIN+2": sigrtmin + 2,
- "RTMIN+3": sigrtmin + 3,
- "RTMIN+4": sigrtmin + 4,
- "RTMIN+5": sigrtmin + 5,
- "RTMIN+6": sigrtmin + 6,
- "RTMIN+7": sigrtmin + 7,
- "RTMIN+8": sigrtmin + 8,
- "RTMIN+9": sigrtmin + 9,
- "RTMIN+10": sigrtmin + 10,
- "RTMIN+11": sigrtmin + 11,
- "RTMIN+12": sigrtmin + 12,
- "RTMIN+13": sigrtmin + 13,
- "RTMIN+14": sigrtmin + 14,
- "RTMIN+15": sigrtmin + 15,
- "RTMAX-14": sigrtmax - 14,
- "RTMAX-13": sigrtmax - 13,
- "RTMAX-12": sigrtmax - 12,
- "RTMAX-11": sigrtmax - 11,
- "RTMAX-10": sigrtmax - 10,
- "RTMAX-9": sigrtmax - 9,
- "RTMAX-8": sigrtmax - 8,
- "RTMAX-7": sigrtmax - 7,
- "RTMAX-6": sigrtmax - 6,
- "RTMAX-5": sigrtmax - 5,
- "RTMAX-4": sigrtmax - 4,
- "RTMAX-3": sigrtmax - 3,
- "RTMAX-2": sigrtmax - 2,
- "RTMAX-1": sigrtmax - 1,
- "RTMAX": sigrtmax,
-}
diff --git a/vendor/github.com/docker/docker/pkg/signal/signal_linux_mipsx.go b/vendor/github.com/docker/docker/pkg/signal/signal_linux_mipsx.go
deleted file mode 100644
index 4c7989121..000000000
--- a/vendor/github.com/docker/docker/pkg/signal/signal_linux_mipsx.go
+++ /dev/null
@@ -1,84 +0,0 @@
-// +build linux
-// +build mips mipsle mips64 mips64le
-
-package signal // import "github.com/docker/docker/pkg/signal"
-
-import (
- "syscall"
-
- "golang.org/x/sys/unix"
-)
-
-const (
- sigrtmin = 34
- sigrtmax = 127
-)
-
-// SignalMap is a map of Linux signals.
-var SignalMap = map[string]syscall.Signal{
- "ABRT": unix.SIGABRT,
- "ALRM": unix.SIGALRM,
- "BUS": unix.SIGBUS,
- "CHLD": unix.SIGCHLD,
- "CLD": unix.SIGCLD,
- "CONT": unix.SIGCONT,
- "FPE": unix.SIGFPE,
- "HUP": unix.SIGHUP,
- "ILL": unix.SIGILL,
- "INT": unix.SIGINT,
- "IO": unix.SIGIO,
- "IOT": unix.SIGIOT,
- "KILL": unix.SIGKILL,
- "PIPE": unix.SIGPIPE,
- "POLL": unix.SIGPOLL,
- "PROF": unix.SIGPROF,
- "PWR": unix.SIGPWR,
- "QUIT": unix.SIGQUIT,
- "SEGV": unix.SIGSEGV,
- "SIGEMT": unix.SIGEMT,
- "STOP": unix.SIGSTOP,
- "SYS": unix.SIGSYS,
- "TERM": unix.SIGTERM,
- "TRAP": unix.SIGTRAP,
- "TSTP": unix.SIGTSTP,
- "TTIN": unix.SIGTTIN,
- "TTOU": unix.SIGTTOU,
- "URG": unix.SIGURG,
- "USR1": unix.SIGUSR1,
- "USR2": unix.SIGUSR2,
- "VTALRM": unix.SIGVTALRM,
- "WINCH": unix.SIGWINCH,
- "XCPU": unix.SIGXCPU,
- "XFSZ": unix.SIGXFSZ,
- "RTMIN": sigrtmin,
- "RTMIN+1": sigrtmin + 1,
- "RTMIN+2": sigrtmin + 2,
- "RTMIN+3": sigrtmin + 3,
- "RTMIN+4": sigrtmin + 4,
- "RTMIN+5": sigrtmin + 5,
- "RTMIN+6": sigrtmin + 6,
- "RTMIN+7": sigrtmin + 7,
- "RTMIN+8": sigrtmin + 8,
- "RTMIN+9": sigrtmin + 9,
- "RTMIN+10": sigrtmin + 10,
- "RTMIN+11": sigrtmin + 11,
- "RTMIN+12": sigrtmin + 12,
- "RTMIN+13": sigrtmin + 13,
- "RTMIN+14": sigrtmin + 14,
- "RTMIN+15": sigrtmin + 15,
- "RTMAX-14": sigrtmax - 14,
- "RTMAX-13": sigrtmax - 13,
- "RTMAX-12": sigrtmax - 12,
- "RTMAX-11": sigrtmax - 11,
- "RTMAX-10": sigrtmax - 10,
- "RTMAX-9": sigrtmax - 9,
- "RTMAX-8": sigrtmax - 8,
- "RTMAX-7": sigrtmax - 7,
- "RTMAX-6": sigrtmax - 6,
- "RTMAX-5": sigrtmax - 5,
- "RTMAX-4": sigrtmax - 4,
- "RTMAX-3": sigrtmax - 3,
- "RTMAX-2": sigrtmax - 2,
- "RTMAX-1": sigrtmax - 1,
- "RTMAX": sigrtmax,
-}
diff --git a/vendor/github.com/docker/docker/pkg/signal/signal_unix.go b/vendor/github.com/docker/docker/pkg/signal/signal_unix.go
deleted file mode 100644
index a2aa4248f..000000000
--- a/vendor/github.com/docker/docker/pkg/signal/signal_unix.go
+++ /dev/null
@@ -1,21 +0,0 @@
-// +build !windows
-
-package signal // import "github.com/docker/docker/pkg/signal"
-
-import (
- "syscall"
-)
-
-// Signals used in cli/command (no windows equivalent, use
-// invalid signals so they don't get handled)
-
-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"
-)
diff --git a/vendor/github.com/docker/docker/pkg/signal/signal_unsupported.go b/vendor/github.com/docker/docker/pkg/signal/signal_unsupported.go
deleted file mode 100644
index 1fd25a83c..000000000
--- a/vendor/github.com/docker/docker/pkg/signal/signal_unsupported.go
+++ /dev/null
@@ -1,10 +0,0 @@
-// +build !linux,!darwin,!freebsd,!windows
-
-package signal // import "github.com/docker/docker/pkg/signal"
-
-import (
- "syscall"
-)
-
-// SignalMap is an empty map of signals for unsupported platform.
-var SignalMap = map[string]syscall.Signal{}
diff --git a/vendor/github.com/docker/docker/pkg/signal/signal_windows.go b/vendor/github.com/docker/docker/pkg/signal/signal_windows.go
deleted file mode 100644
index 65752f24a..000000000
--- a/vendor/github.com/docker/docker/pkg/signal/signal_windows.go
+++ /dev/null
@@ -1,26 +0,0 @@
-package signal // import "github.com/docker/docker/pkg/signal"
-
-import (
- "syscall"
-)
-
-// Signals used in cli/command (no windows equivalent, use
-// invalid signals so they don't get handled)
-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"
-)
-
-// 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.
-var SignalMap = map[string]syscall.Signal{
- "KILL": syscall.SIGKILL,
- "TERM": syscall.SIGTERM,
-}
diff --git a/vendor/github.com/docker/docker/pkg/signal/trap.go b/vendor/github.com/docker/docker/pkg/signal/trap.go
deleted file mode 100644
index a277b9562..000000000
--- a/vendor/github.com/docker/docker/pkg/signal/trap.go
+++ /dev/null
@@ -1,104 +0,0 @@
-package signal // import "github.com/docker/docker/pkg/signal"
-
-import (
- "fmt"
- "os"
- gosignal "os/signal"
- "path/filepath"
- "runtime"
- "strings"
- "sync/atomic"
- "syscall"
- "time"
-
- "github.com/pkg/errors"
-)
-
-// 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 Trap(cleanup func(), logger interface {
- Info(args ...interface{})
-}) {
- c := make(chan os.Signal, 1)
- // we will handle INT, TERM, QUIT, SIGPIPE here
- signals := []os.Signal{os.Interrupt, syscall.SIGTERM, syscall.SIGQUIT, syscall.SIGPIPE}
- gosignal.Notify(c, signals...)
- go func() {
- interruptCount := uint32(0)
- for sig := range c {
- if sig == syscall.SIGPIPE {
- continue
- }
-
- go func(sig os.Signal) {
- logger.Info(fmt.Sprintf("Processing signal '%v'", sig))
- switch sig {
- case os.Interrupt, syscall.SIGTERM:
- if atomic.LoadUint32(&interruptCount) < 3 {
- // Initiate the cleanup only once
- if atomic.AddUint32(&interruptCount, 1) == 1 {
- // Call the provided cleanup handler
- cleanup()
- os.Exit(0)
- } else {
- return
- }
- } else {
- // 3 SIGTERM/INT signals received; force exit without cleanup
- logger.Info("Forcing docker daemon shutdown without cleanup; 3 interrupts received")
- }
- case syscall.SIGQUIT:
- DumpStacks("")
- logger.Info("Forcing docker daemon shutdown without cleanup on SIGQUIT")
- }
- // for the SIGINT/TERM, and SIGQUIT non-clean shutdown case, exit with 128 + signal #
- os.Exit(128 + int(sig.(syscall.Signal)))
- }(sig)
- }
- }()
-}
-
-const stacksLogNameTemplate = "goroutine-stacks-%s.log"
-
-// DumpStacks appends the runtime stack into file in dir and returns full path
-// to that file.
-func DumpStacks(dir string) (string, error) {
- var (
- buf []byte
- stackSize int
- )
- bufferLen := 16384
- for stackSize == len(buf) {
- buf = make([]byte, bufferLen)
- stackSize = runtime.Stack(buf, true)
- bufferLen *= 2
- }
- buf = buf[:stackSize]
- var f *os.File
- if dir != "" {
- path := filepath.Join(dir, fmt.Sprintf(stacksLogNameTemplate, strings.Replace(time.Now().Format(time.RFC3339), ":", "", -1)))
- var err error
- f, err = os.OpenFile(path, os.O_CREATE|os.O_WRONLY, 0666)
- if err != nil {
- return "", errors.Wrap(err, "failed to open file to write the goroutine stacks")
- }
- defer f.Close()
- defer f.Sync()
- } else {
- f = os.Stderr
- }
- if _, err := f.Write(buf); err != nil {
- return "", errors.Wrap(err, "failed to write goroutine stacks")
- }
- return f.Name(), nil
-}
diff --git a/vendor/modules.txt b/vendor/modules.txt
index 3c03fbdfb..69f2bed8e 100644
--- a/vendor/modules.txt
+++ b/vendor/modules.txt
@@ -238,7 +238,6 @@ github.com/docker/docker/pkg/mount
github.com/docker/docker/pkg/namesgenerator
github.com/docker/docker/pkg/parsers
github.com/docker/docker/pkg/pools
-github.com/docker/docker/pkg/signal
github.com/docker/docker/pkg/stdcopy
github.com/docker/docker/pkg/system
github.com/docker/docker/pkg/term