X-Git-Url: http://www.git.cypherpunks.ru/?a=blobdiff_plain;f=run.go;h=0178d726b9d9b476dbd01d1db45e713d0f5c80c0;hb=bf96757828d2ae663f5f54147c0e229f74fc9357;hp=7128bb8b3f581f036f06170f98eac9afa0c5f6f8;hpb=3712058fedf40a36a623c6e9283e36eccf80619c;p=goredo.git diff --git a/run.go b/run.go index 7128bb8..0178d72 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() { @@ -140,7 +143,7 @@ func isModified(cwd, redoDir, tgt string) (bool, *Inode, error) { } return false, nil, err } - if m["Target"] != tgt { + if m["Type"] != DepTypeIfchange || m["Target"] != tgt { continue } fd, err := os.Open(path.Join(cwd, tgt)) @@ -479,7 +482,7 @@ func runScript(tgtOrig string, errs chan error, traced bool) error { }) fields = append(fields, recfile.Field{Name: "Cmd", Value: cmdName}) for _, arg := range args { - fields = append(fields, recfile.Field{Name: "Cmd", Value: arg}) + fields = append(fields, recfile.Field{Name: "Arg", Value: arg}) } for _, env := range cmd.Env { fields = append(fields, recfile.Field{Name: "Env", Value: env}) @@ -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 {