signalHandler forwards all the signals to the cmd.
(cmd *exec.Cmd, exitCh chan int)
| 198 | |
| 199 | // signalHandler forwards all the signals to the cmd. |
| 200 | func signalHandler(cmd *exec.Cmd, exitCh chan int) { |
| 201 | // signal.Notify prefers a buffered channel. From documentation: "For a |
| 202 | // channel used for notification of just one signal value, a buffer of size |
| 203 | // 1 is sufficient." As we do not know how many signal values the cmd is |
| 204 | // expecting we select 1 as a sane default. In the future maybe we can make |
| 205 | // this value configurable. |
| 206 | signals := make(chan os.Signal, 1) |
| 207 | signal.Notify(signals) |
| 208 | defer signal.Stop(signals) |
| 209 | for { |
| 210 | select { |
| 211 | case sig := <-signals: |
| 212 | cmd.Process.Signal(sig) |
| 213 | case code := <-exitCh: |
| 214 | //nolint:gocritic // ignore exitAfterDefer error - defer is required for recovery. |
| 215 | os.Exit(code) |
| 216 | } |
| 217 | } |
| 218 | } |
no outgoing calls
no test coverage detected
searching dependent graphs…