mirror of
https://github.com/Hilbis/Hilbish
synced 2025-03-22 22:40:41 +00:00
* refactor: use custom event emitter * fix: sigint hook emit on windows * fix: restore correct hilbish conf file * fix: call recoverer for go listeners * refactor(golibs/bait): use 1 map for listeners * feat: add once listeners, ability to remove listeners and remove listener on error * perf: reslice listener slice instead of trying to do ordered move with append * feat(bait): add release function to remove event listener * perf: remove listener directly from once emit instead of using off function * refactor: use bait event emitter on commander * docs(golibs/bait): add doc strings for functions * docs: set changelog * docs(golibs/bait): add docs for lua release function
26 lines
597 B
Go
26 lines
597 B
Go
// +build darwin linux
|
|
|
|
package main
|
|
|
|
import (
|
|
"syscall"
|
|
"os"
|
|
"os/signal"
|
|
)
|
|
|
|
func handleSignals() {
|
|
c := make(chan os.Signal)
|
|
signal.Ignore(syscall.SIGTTOU, syscall.SIGTTIN, syscall.SIGTSTP)
|
|
signal.Notify(c, os.Interrupt, syscall.SIGTERM, syscall.SIGWINCH, syscall.SIGUSR1, syscall.SIGUSR2, syscall.SIGQUIT)
|
|
|
|
for s := range c {
|
|
switch s {
|
|
case os.Interrupt: hooks.Emit("signal.sigint")
|
|
case syscall.SIGTERM: exit(0)
|
|
case syscall.SIGWINCH: hooks.Emit("signal.resize")
|
|
case syscall.SIGUSR1: hooks.Emit("signal.sigusr1")
|
|
case syscall.SIGUSR2: hooks.Emit("signal.sigusr2")
|
|
}
|
|
}
|
|
}
|