#chan not receiving SIGTERM from external process handle
19 messages · Page 1 of 1 (latest)
Are you using os/signal?
yup
yup
sc = make(chan os.Signal)
signal.Notify(sc, syscall.SIGINT, syscall.SIGTERM)
<-sc
conductShutdown()
...
func conductShutdown() {
println("shutting down server")
err := dbRunner.Shutdown()
if err != nil {
println(fmt.Sprintf("failed to shutdown database: %s", err.Error()))
}
}
JS
processHandle?.kill('SIGTERM')
And yes, when handling it any other way, it does work.
wdmym by when handling it any other way ?
can you explain?
I think they mean by sending the signal by other means
Correct, I think the issue lies in SIGTERM, nodejs does not handle SIGTERM on windows but does SIGINT. So I swapped that out and it looks to be working now.
Also needed to change the make to make(chan os.Signal, 1)
Actually it still doesnt work lol
while windows does use signals, it's not unix, there is no SIGTERM on windows. SIGINT should work tho
well there is for ANSI compat, but not as you'd expect. You can find more info here https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/signal?view=msvc-170
also don't use println, especially not println(fmt.Sprintf(...)) use fmt.Println or fmt.Printf
also note this excerpt from nodejs docs "Windows does not support signals so has no equivalent to termination by signal, but Node.js offers some emulation with process.kill(), and subprocess.kill():" https://nodejs.org/api/process.html. Either way this seems like a node question, not a go one so I'd try my luck with the node community.