vrecan/death

doesn't seem to work properly on windows for ctrl+c handling.

tensor-programming opened this issue · 1 comments

I am running a badgerDB example for a tutorial that I am working on. I added a network competent that runs with the DB open while receiving RPC from another client. The only way to shut down the client is by issuing a ctrl+c command. Badger has a few issues with windows because it needs to garbage collect its values before exiting. The main problem though is that I can't get windows to gracefully shutdown the program when I execute a ctrl+c break. With Death, the ctrl+c break doesn't even seem to register, instead I have to open task manager and force the process to stop. Is there any way I can work around this or am I just missing something.

Here is what my closeDB function looks like,

func CloseDB(db *badger.DB) {
	d := death.NewDeath(syscall.SIGINT, syscall.SIGTERM, os.Interrupt)

	d.WaitForDeathWithFunc(func() {
		defer runtime.Goexit()
		db.Close()
	})
}

I am running the runtime.Goexit because there are other defer commands that I want to honor before closing the database and then exiting the program. I've also tried just running NewDeath with syscall.SIGINT or os.Interrupt to no avail.

figured out how to deal with this issue.