github.com/containers/podman/v4@v4.9.4/pkg/signal/signal_linux.go (about)

     1  //go:build linux && !mips && !mipsle && !mips64 && !mips64le
     2  // +build linux,!mips,!mipsle,!mips64,!mips64le
     3  
     4  // Signal handling for Linux only.
     5  package signal
     6  
     7  // Copyright 2013-2018 Docker, Inc.
     8  
     9  // NOTE: this package has originally been copied from github.com/docker/docker.
    10  
    11  import (
    12  	"syscall"
    13  
    14  	"golang.org/x/sys/unix"
    15  )
    16  
    17  const (
    18  	sigrtmin = 34
    19  	sigrtmax = 64
    20  
    21  	SIGWINCH = syscall.SIGWINCH // For cross-compilation with Windows
    22  )
    23  
    24  // SignalMap is a map of Linux signals.
    25  var SignalMap = map[string]syscall.Signal{
    26  	"ABRT":     unix.SIGABRT,
    27  	"ALRM":     unix.SIGALRM,
    28  	"BUS":      unix.SIGBUS,
    29  	"CHLD":     unix.SIGCHLD,
    30  	"CLD":      unix.SIGCLD,
    31  	"CONT":     unix.SIGCONT,
    32  	"FPE":      unix.SIGFPE,
    33  	"HUP":      unix.SIGHUP,
    34  	"ILL":      unix.SIGILL,
    35  	"INT":      unix.SIGINT,
    36  	"IO":       unix.SIGIO,
    37  	"IOT":      unix.SIGIOT,
    38  	"KILL":     unix.SIGKILL,
    39  	"PIPE":     unix.SIGPIPE,
    40  	"POLL":     unix.SIGPOLL,
    41  	"PROF":     unix.SIGPROF,
    42  	"PWR":      unix.SIGPWR,
    43  	"QUIT":     unix.SIGQUIT,
    44  	"SEGV":     unix.SIGSEGV,
    45  	"STKFLT":   unix.SIGSTKFLT,
    46  	"STOP":     unix.SIGSTOP,
    47  	"SYS":      unix.SIGSYS,
    48  	"TERM":     unix.SIGTERM,
    49  	"TRAP":     unix.SIGTRAP,
    50  	"TSTP":     unix.SIGTSTP,
    51  	"TTIN":     unix.SIGTTIN,
    52  	"TTOU":     unix.SIGTTOU,
    53  	"URG":      unix.SIGURG,
    54  	"USR1":     unix.SIGUSR1,
    55  	"USR2":     unix.SIGUSR2,
    56  	"VTALRM":   unix.SIGVTALRM,
    57  	"WINCH":    unix.SIGWINCH,
    58  	"XCPU":     unix.SIGXCPU,
    59  	"XFSZ":     unix.SIGXFSZ,
    60  	"RTMIN":    sigrtmin,
    61  	"RTMIN+1":  sigrtmin + 1,
    62  	"RTMIN+2":  sigrtmin + 2,
    63  	"RTMIN+3":  sigrtmin + 3,
    64  	"RTMIN+4":  sigrtmin + 4,
    65  	"RTMIN+5":  sigrtmin + 5,
    66  	"RTMIN+6":  sigrtmin + 6,
    67  	"RTMIN+7":  sigrtmin + 7,
    68  	"RTMIN+8":  sigrtmin + 8,
    69  	"RTMIN+9":  sigrtmin + 9,
    70  	"RTMIN+10": sigrtmin + 10,
    71  	"RTMIN+11": sigrtmin + 11,
    72  	"RTMIN+12": sigrtmin + 12,
    73  	"RTMIN+13": sigrtmin + 13,
    74  	"RTMIN+14": sigrtmin + 14,
    75  	"RTMIN+15": sigrtmin + 15,
    76  	"RTMAX-14": sigrtmax - 14,
    77  	"RTMAX-13": sigrtmax - 13,
    78  	"RTMAX-12": sigrtmax - 12,
    79  	"RTMAX-11": sigrtmax - 11,
    80  	"RTMAX-10": sigrtmax - 10,
    81  	"RTMAX-9":  sigrtmax - 9,
    82  	"RTMAX-8":  sigrtmax - 8,
    83  	"RTMAX-7":  sigrtmax - 7,
    84  	"RTMAX-6":  sigrtmax - 6,
    85  	"RTMAX-5":  sigrtmax - 5,
    86  	"RTMAX-4":  sigrtmax - 4,
    87  	"RTMAX-3":  sigrtmax - 3,
    88  	"RTMAX-2":  sigrtmax - 2,
    89  	"RTMAX-1":  sigrtmax - 1,
    90  	"RTMAX":    sigrtmax,
    91  }
    92  
    93  // IsSignalIgnoredBySigProxy determines whether sig-proxy should ignore syscall signal
    94  func IsSignalIgnoredBySigProxy(s syscall.Signal) bool {
    95  	// Ignore SIGCHLD and SIGPIPE - these are most likely intended for the podman command itself.
    96  	// SIGURG was added because of golang 1.14 and its preemptive changes causing more signals to "show up".
    97  	// https://github.com/containers/podman/issues/5483
    98  	return s == syscall.SIGCHLD || s == syscall.SIGPIPE || s == syscall.SIGURG
    99  }