X-Git-Url: http://www.git.cypherpunks.ru/?p=goredo.git;a=blobdiff_plain;f=run.go;h=ca514578fcc9feaa0ee4d5d1110b09a427585d50;hp=1e8472f3602b514f9335712028411f48f5c163a0;hb=9485b9805119a388f1d4d93d18b0fe1a2da212a0;hpb=94ace13349ab0f38aaa046d01ef1a3c00f1ea6f1 diff --git a/run.go b/run.go index 1e8472f..ca51457 100644 --- 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 {