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

     1  //go:build aix || darwin || dragonfly || freebsd || netbsd || openbsd || solaris || zos
     2  // +build aix darwin dragonfly freebsd netbsd openbsd solaris zos
     3  
     4  // Signal handling for Linux only.
     5  package signal
     6  
     7  import (
     8  	"syscall"
     9  )
    10  
    11  const (
    12  	sigrtmin = 34
    13  	sigrtmax = 64
    14  
    15  	SIGWINCH = syscall.SIGWINCH
    16  )
    17  
    18  // SignalMap is a map of Linux signals.
    19  // These constants are sourced from the Linux version of golang.org/x/sys/unix
    20  // (I don't see much risk of this changing).
    21  // This should work as long as Podman only runs containers on Linux, which seems
    22  // a safe assumption for now.
    23  var SignalMap = map[string]syscall.Signal{
    24  	"ABRT":     syscall.Signal(0x6),
    25  	"ALRM":     syscall.Signal(0xe),
    26  	"BUS":      syscall.Signal(0x7),
    27  	"CHLD":     syscall.Signal(0x11),
    28  	"CLD":      syscall.Signal(0x11),
    29  	"CONT":     syscall.Signal(0x12),
    30  	"FPE":      syscall.Signal(0x8),
    31  	"HUP":      syscall.Signal(0x1),
    32  	"ILL":      syscall.Signal(0x4),
    33  	"INT":      syscall.Signal(0x2),
    34  	"IO":       syscall.Signal(0x1d),
    35  	"IOT":      syscall.Signal(0x6),
    36  	"KILL":     syscall.Signal(0x9),
    37  	"PIPE":     syscall.Signal(0xd),
    38  	"POLL":     syscall.Signal(0x1d),
    39  	"PROF":     syscall.Signal(0x1b),
    40  	"PWR":      syscall.Signal(0x1e),
    41  	"QUIT":     syscall.Signal(0x3),
    42  	"SEGV":     syscall.Signal(0xb),
    43  	"STKFLT":   syscall.Signal(0x10),
    44  	"STOP":     syscall.Signal(0x13),
    45  	"SYS":      syscall.Signal(0x1f),
    46  	"TERM":     syscall.Signal(0xf),
    47  	"TRAP":     syscall.Signal(0x5),
    48  	"TSTP":     syscall.Signal(0x14),
    49  	"TTIN":     syscall.Signal(0x15),
    50  	"TTOU":     syscall.Signal(0x16),
    51  	"URG":      syscall.Signal(0x17),
    52  	"USR1":     syscall.Signal(0xa),
    53  	"USR2":     syscall.Signal(0xc),
    54  	"VTALRM":   syscall.Signal(0x1a),
    55  	"WINCH":    syscall.Signal(0x1c),
    56  	"XCPU":     syscall.Signal(0x18),
    57  	"XFSZ":     syscall.Signal(0x19),
    58  	"RTMIN":    sigrtmin,
    59  	"RTMIN+1":  sigrtmin + 1,
    60  	"RTMIN+2":  sigrtmin + 2,
    61  	"RTMIN+3":  sigrtmin + 3,
    62  	"RTMIN+4":  sigrtmin + 4,
    63  	"RTMIN+5":  sigrtmin + 5,
    64  	"RTMIN+6":  sigrtmin + 6,
    65  	"RTMIN+7":  sigrtmin + 7,
    66  	"RTMIN+8":  sigrtmin + 8,
    67  	"RTMIN+9":  sigrtmin + 9,
    68  	"RTMIN+10": sigrtmin + 10,
    69  	"RTMIN+11": sigrtmin + 11,
    70  	"RTMIN+12": sigrtmin + 12,
    71  	"RTMIN+13": sigrtmin + 13,
    72  	"RTMIN+14": sigrtmin + 14,
    73  	"RTMIN+15": sigrtmin + 15,
    74  	"RTMAX-14": sigrtmax - 14,
    75  	"RTMAX-13": sigrtmax - 13,
    76  	"RTMAX-12": sigrtmax - 12,
    77  	"RTMAX-11": sigrtmax - 11,
    78  	"RTMAX-10": sigrtmax - 10,
    79  	"RTMAX-9":  sigrtmax - 9,
    80  	"RTMAX-8":  sigrtmax - 8,
    81  	"RTMAX-7":  sigrtmax - 7,
    82  	"RTMAX-6":  sigrtmax - 6,
    83  	"RTMAX-5":  sigrtmax - 5,
    84  	"RTMAX-4":  sigrtmax - 4,
    85  	"RTMAX-3":  sigrtmax - 3,
    86  	"RTMAX-2":  sigrtmax - 2,
    87  	"RTMAX-1":  sigrtmax - 1,
    88  	"RTMAX":    sigrtmax,
    89  }
    90  
    91  // IsSignalIgnoredBySigProxy determines whether sig-proxy should ignore syscall signal
    92  func IsSignalIgnoredBySigProxy(s syscall.Signal) bool {
    93  	// Ignore SIGCHLD and SIGPIPE - these are most likely intended for the podman command itself.
    94  	// SIGURG was added because of golang 1.14 and its preemptive changes causing more signals to "show up".
    95  	// https://github.com/containers/podman/issues/5483
    96  	return s == syscall.SIGCHLD || s == syscall.SIGPIPE || s == syscall.SIGURG
    97  }