Signal is called when an os.Signal is received, and guarantees that all notifications are executed, then the final handler is executed. This function should only be called once per Handler instance.
(s os.Signal)
| 60 | // are executed, then the final handler is executed. This function should only be called once |
| 61 | // per Handler instance. |
| 62 | func (h *Handler) Signal(s os.Signal) { |
| 63 | h.once.Do(func() { |
| 64 | for _, fn := range h.notify { |
| 65 | fn() |
| 66 | } |
| 67 | if h.final == nil { |
| 68 | os.Exit(1) |
| 69 | } |
| 70 | h.final(s) |
| 71 | }) |
| 72 | } |
| 73 | |
| 74 | // Run ensures that any notifications are invoked after the provided fn exits (even if the |
| 75 | // process is interrupted by an OS termination signal). Notifications are only invoked once |
no outgoing calls
no test coverage detected