This commit is contained in:
2023-12-08 15:15:35 +11:00
parent a4ba011b36
commit eb7bde3cbe
10 changed files with 225 additions and 27 deletions
+8 -2
View File
@@ -1,15 +1,18 @@
package init
import (
"golang.org/x/sys/unix"
"os"
"os/signal"
"sync"
"golang.org/x/sys/unix"
)
func (i *Init) sighandler(wg *sync.WaitGroup, trigger chan<- any, selfExit <-chan any) {
defer wg.Wait()
isOpen := true
c := make(chan os.Signal, 1)
signal.Notify(c, unix.SIGINT, unix.SIGTERM, unix.SIGCHLD)
@@ -19,7 +22,10 @@ signal:
case s := <-c:
switch s {
case unix.SIGTERM, unix.SIGINT:
close(trigger)
if isOpen {
close(trigger)
isOpen = false
}
case unix.SIGCHLD:
// do nothing
}