From 02bc535e0efcf1943c78411ec8c37fe2a017c3bb Mon Sep 17 00:00:00 2001 From: Jae Kwon Date: Thu, 16 Apr 2015 19:04:21 -0700 Subject: [PATCH] Close files upon stop. Still need to fix bash issues? --- common/os.go | 1 + process/process.go | 1 + 2 files changed, 2 insertions(+) diff --git a/common/os.go b/common/os.go index 5f7959474..bab5fbce6 100644 --- a/common/os.go +++ b/common/os.go @@ -9,6 +9,7 @@ import ( func TrapSignal(cb func()) { c := make(chan os.Signal, 1) signal.Notify(c, os.Interrupt) + signal.Notify(c, os.Kill) go func() { for sig := range c { fmt.Printf("captured %v, exiting...\n", sig) diff --git a/process/process.go b/process/process.go index be4a0ad6d..c4e8a7592 100644 --- a/process/process.go +++ b/process/process.go @@ -84,6 +84,7 @@ func Create(mode int, label string, execPath string, args []string, input string } func Stop(proc *Process, kill bool) error { + defer proc.OutputFile.Close() if kill { fmt.Printf("Killing process %v\n", proc.Cmd.Process) return proc.Cmd.Process.Kill()