unix - Capturing kill code of go process? -


i'm trying write test drive out functionality kill commands. this, need target of test (a simple go http server - https://github.com/jadekler/git-grunt-gostop/blob/master/test/fixtures/gostop_basic.go) differentiate between having been killing -2 vs -9. there way this? seems though go's defer doesn't happen regardless of -2 vs -9, first try. subsequent research has not been enlightening.

thanks suggestions!

you can catch signals using os/signal package. can catch sigint code this:

import (     "os"     "os/signal" ) ...  // signal module lose notifications if channel not ready receive, give buffer ch := make(chan os.signal, 5) go func() {     sig := range ch {         // interrupt signal received         os.exit(0)     } }() signal.notify(ch, os.sigint) 

unfortunately, can't same sigkill. signal(7) man page:

the signals sigkill , sigstop cannot caught, blocked, or ignored.


Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

nvd3.js - angularjs-nvd3-directives setting color in legend as well as in chart elements -