aboutsummaryrefslogtreecommitdiff
path: root/pkg/signal/signal_linux.go
diff options
context:
space:
mode:
authorMatthew Heon <mheon@redhat.com>2020-05-28 14:12:19 -0400
committerMatthew Heon <mheon@redhat.com>2020-05-28 14:26:36 -0400
commite0eb6022b32f4261dbd5b78d958afc15ec2af297 (patch)
treeec86bfe91fd45d20d67619d4d9b5a3a70c033ad0 /pkg/signal/signal_linux.go
parente704da0c520bfc1d8e0462983e8470040a2fda9d (diff)
downloadpodman-e0eb6022b32f4261dbd5b78d958afc15ec2af297.tar.gz
podman-e0eb6022b32f4261dbd5b78d958afc15ec2af297.tar.bz2
podman-e0eb6022b32f4261dbd5b78d958afc15ec2af297.zip
Ensure that signal names can be parsed on Windows
To ensure the Windows and OS X remote clients can properly parse container stop signal (when given as a name e.g. SIGTERM) and set it in SpecGen, we need access to a list of Linux signal names and the numbers they map to that is available on non-Linux OSes. Fortunately, these are ABI constants that are extremely unlikely to change, so we can just take the existing constant definitions from the library and use them. The signal numbers used here are sourced from AMD64, but should be the same for every architecture that is not Alpha, SPARC, MIPS, and PA-RISC. So `podman run --stop-signal SIGTTOU` from a Windows client to a Podman service on a SPARC host will set an incorrect stop signal, but I don't think this is a large problem. Signed-off-by: Matthew Heon <mheon@redhat.com>
Diffstat (limited to 'pkg/signal/signal_linux.go')
-rw-r--r--pkg/signal/signal_linux.go36
1 files changed, 0 insertions, 36 deletions
diff --git a/pkg/signal/signal_linux.go b/pkg/signal/signal_linux.go
index e6e0f1ca1..6eebf7e5a 100644
--- a/pkg/signal/signal_linux.go
+++ b/pkg/signal/signal_linux.go
@@ -8,11 +8,8 @@ package signal
// NOTE: this package has originally been copied from github.com/docker/docker.
import (
- "fmt"
"os"
"os/signal"
- "strconv"
- "strings"
"syscall"
"golang.org/x/sys/unix"
@@ -94,23 +91,6 @@ var signalMap = map[string]syscall.Signal{
"RTMAX": sigrtmax,
}
-// 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
- }
- sig, ok := signalMap[strings.TrimPrefix(strings.ToUpper(rawSignal), "SIG")]
- if !ok {
- return -1, fmt.Errorf("invalid signal: %s", rawSignal)
- }
- return sig, nil
-}
-
// CatchAll catches all signals and relays them to the specified channel.
func CatchAll(sigc chan os.Signal) {
var handledSigs []os.Signal
@@ -125,19 +105,3 @@ func StopCatch(sigc chan os.Signal) {
signal.Stop(sigc)
close(sigc)
}
-
-// ParseSignalNameOrNumber translates a string to a valid syscall signal. Input
-// can be a name or number representation i.e. "KILL" "9"
-func ParseSignalNameOrNumber(rawSignal string) (syscall.Signal, error) {
- basename := strings.TrimPrefix(rawSignal, "-")
- s, err := ParseSignal(basename)
- if err == nil {
- return s, nil
- }
- for k, v := range signalMap {
- if k == strings.ToUpper(basename) {
- return v, nil
- }
- }
- return -1, fmt.Errorf("invalid signal: %s", basename)
-}