You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

134 lines
3.5 KiB

  1. From 1ad796677e1ce3f03463c791818176586987c389 Mon Sep 17 00:00:00 2001
  2. From: Paul Holzinger <paul.holzinger@web.de>
  3. Date: Mon, 21 Dec 2020 12:30:06 +0100
  4. Subject: [PATCH] Fix build for mips architecture
  5. The signal SIGSTKFLT does not exists on mips architectures.
  6. Also RTMIN and RTMAX are different.
  7. This code is copied from docker.
  8. Signed-off-by: Paul Holzinger <paul.holzinger@web.de>
  9. ---
  10. pkg/signal/signal_linux.go | 1 +
  11. pkg/signal/signal_linux_mipsx.go | 106 +++++++++++++++++++++++++++++++
  12. 2 files changed, 107 insertions(+)
  13. create mode 100644 pkg/signal/signal_linux_mipsx.go
  14. --- a/pkg/signal/signal_linux.go
  15. +++ b/pkg/signal/signal_linux.go
  16. @@ -1,4 +1,5 @@
  17. // +build linux
  18. +// +build !mips,!mipsle,!mips64,!mips64le
  19. // Signal handling for Linux only.
  20. package signal
  21. --- /dev/null
  22. +++ b/pkg/signal/signal_linux_mipsx.go
  23. @@ -0,0 +1,106 @@
  24. +// +build linux
  25. +// +build mips mipsle mips64 mips64le
  26. +
  27. +// Special signal handling for mips architecture
  28. +package signal
  29. +
  30. +// Copyright 2013-2018 Docker, Inc.
  31. +
  32. +// NOTE: this package has originally been copied from github.com/docker/docker.
  33. +
  34. +import (
  35. + "os"
  36. + "os/signal"
  37. + "syscall"
  38. +
  39. + "golang.org/x/sys/unix"
  40. +)
  41. +
  42. +const (
  43. + sigrtmin = 34
  44. + sigrtmax = 127
  45. +)
  46. +
  47. +// signalMap is a map of Linux signals.
  48. +var signalMap = map[string]syscall.Signal{
  49. + "ABRT": unix.SIGABRT,
  50. + "ALRM": unix.SIGALRM,
  51. + "BUS": unix.SIGBUS,
  52. + "CHLD": unix.SIGCHLD,
  53. + "CLD": unix.SIGCLD,
  54. + "CONT": unix.SIGCONT,
  55. + "FPE": unix.SIGFPE,
  56. + "HUP": unix.SIGHUP,
  57. + "ILL": unix.SIGILL,
  58. + "INT": unix.SIGINT,
  59. + "IO": unix.SIGIO,
  60. + "IOT": unix.SIGIOT,
  61. + "KILL": unix.SIGKILL,
  62. + "PIPE": unix.SIGPIPE,
  63. + "POLL": unix.SIGPOLL,
  64. + "PROF": unix.SIGPROF,
  65. + "PWR": unix.SIGPWR,
  66. + "QUIT": unix.SIGQUIT,
  67. + "SEGV": unix.SIGSEGV,
  68. + "EMT": unix.SIGEMT,
  69. + "STOP": unix.SIGSTOP,
  70. + "SYS": unix.SIGSYS,
  71. + "TERM": unix.SIGTERM,
  72. + "TRAP": unix.SIGTRAP,
  73. + "TSTP": unix.SIGTSTP,
  74. + "TTIN": unix.SIGTTIN,
  75. + "TTOU": unix.SIGTTOU,
  76. + "URG": unix.SIGURG,
  77. + "USR1": unix.SIGUSR1,
  78. + "USR2": unix.SIGUSR2,
  79. + "VTALRM": unix.SIGVTALRM,
  80. + "WINCH": unix.SIGWINCH,
  81. + "XCPU": unix.SIGXCPU,
  82. + "XFSZ": unix.SIGXFSZ,
  83. + "RTMIN": sigrtmin,
  84. + "RTMIN+1": sigrtmin + 1,
  85. + "RTMIN+2": sigrtmin + 2,
  86. + "RTMIN+3": sigrtmin + 3,
  87. + "RTMIN+4": sigrtmin + 4,
  88. + "RTMIN+5": sigrtmin + 5,
  89. + "RTMIN+6": sigrtmin + 6,
  90. + "RTMIN+7": sigrtmin + 7,
  91. + "RTMIN+8": sigrtmin + 8,
  92. + "RTMIN+9": sigrtmin + 9,
  93. + "RTMIN+10": sigrtmin + 10,
  94. + "RTMIN+11": sigrtmin + 11,
  95. + "RTMIN+12": sigrtmin + 12,
  96. + "RTMIN+13": sigrtmin + 13,
  97. + "RTMIN+14": sigrtmin + 14,
  98. + "RTMIN+15": sigrtmin + 15,
  99. + "RTMAX-14": sigrtmax - 14,
  100. + "RTMAX-13": sigrtmax - 13,
  101. + "RTMAX-12": sigrtmax - 12,
  102. + "RTMAX-11": sigrtmax - 11,
  103. + "RTMAX-10": sigrtmax - 10,
  104. + "RTMAX-9": sigrtmax - 9,
  105. + "RTMAX-8": sigrtmax - 8,
  106. + "RTMAX-7": sigrtmax - 7,
  107. + "RTMAX-6": sigrtmax - 6,
  108. + "RTMAX-5": sigrtmax - 5,
  109. + "RTMAX-4": sigrtmax - 4,
  110. + "RTMAX-3": sigrtmax - 3,
  111. + "RTMAX-2": sigrtmax - 2,
  112. + "RTMAX-1": sigrtmax - 1,
  113. + "RTMAX": sigrtmax,
  114. +}
  115. +
  116. +// CatchAll catches all signals and relays them to the specified channel.
  117. +func CatchAll(sigc chan os.Signal) {
  118. + handledSigs := make([]os.Signal, 0, len(signalMap))
  119. + for _, s := range signalMap {
  120. + handledSigs = append(handledSigs, s)
  121. + }
  122. + signal.Notify(sigc, handledSigs...)
  123. +}
  124. +
  125. +// StopCatch stops catching the signals and closes the specified channel.
  126. +func StopCatch(sigc chan os.Signal) {
  127. + signal.Stop(sigc)
  128. + close(sigc)
  129. +}