diff --git a/headless9 b/headless9 deleted file mode 100755 index 2e2ed02..0000000 Binary files a/headless9 and /dev/null differ diff --git a/main.go b/main.go index f495f59..460ae29 100644 --- a/main.go +++ b/main.go @@ -43,6 +43,7 @@ func main() { } func execCommand(cmd string, arg ...string) { + defer PanicSafe() proc := exec.Command(cmd, arg...) // open the out file for writing outfile, err := os.Create(fmt.Sprintf("/adm/log/%+v.log", cmd)) @@ -104,3 +105,12 @@ func watchFile(filePath string) error { return nil } + + +// PanicSafe is a deferrable function to recover from a panic operation. +func PanicSafe(a ...interface{}) { + if r := recover(); r != nil { + log.Printf("Panic detected: %+v", r) + log.Printf("Optional panic data: %+v", a...) + } +} \ No newline at end of file