]> Cypherpunks.ru repositories - goredo.git/blobdiff - run.go
Kill children
[goredo.git] / run.go
diff --git a/run.go b/run.go
index 1e8472f3602b514f9335712028411f48f5c163a0..ca514578fcc9feaa0ee4d5d1110b09a427585d50 100644 (file)
--- a/run.go
+++ b/run.go
@@ -73,6 +73,9 @@ var (
        flagStderrSilent *bool
 
        TracedAll bool
+
+       RunningProcs  = map[int]*os.Process{}
+       RunningProcsM sync.Mutex
 )
 
 func init() {
@@ -546,6 +549,9 @@ func runScript(tgtOrig string, errs chan error, traced bool) error {
                        errs <- runErr
                        return
                }
+               RunningProcsM.Lock()
+               RunningProcs[cmd.Process.Pid] = cmd.Process
+               RunningProcsM.Unlock()
                pid := fmt.Sprintf("[%d]", cmd.Process.Pid)
                trace(CDebug, "%s runs %s", tgtOrig, pid)
 
@@ -582,6 +588,9 @@ func runScript(tgtOrig string, errs chan error, traced bool) error {
                // Wait for job completion
                <-stderrTerm
                err = cmd.Wait()
+               RunningProcsM.Lock()
+               delete(RunningProcs, cmd.Process.Pid)
+               RunningProcsM.Unlock()
                finished = time.Now()
                runErr.Finished = &finished
                if err != nil {