]> Cypherpunks.ru repositories - goredo.git/blobdiff - run.go
Prevent race
[goredo.git] / run.go
diff --git a/run.go b/run.go
index 7a4c1e4bde43da2762c8f23bcce5f5e6299e541b..7ca2a70d5c6f6359881cd6a0bdafba574db0d232 100644 (file)
--- a/run.go
+++ b/run.go
@@ -289,9 +289,11 @@ func runScript(tgt *Tgt, errs chan error, forced, traced bool) error {
                if StopIfMod {
                        return fmt.Errorf("%s externally modified", tgt)
                }
+               Jobs.Add(1)
                tracef(CWarn, "%s externally modified: not redoing", tgt)
                go func() {
                        errs <- nil
+                       Jobs.Done()
                }()
                return nil
        }
@@ -628,9 +630,11 @@ func runScript(tgt *Tgt, errs chan error, forced, traced bool) error {
                                line = scanner.Text()
                                if strings.HasPrefix(line, childStderrPrefix) {
                                        line = line[len(childStderrPrefix):]
-                                       LogMutex.Lock()
-                                       os.Stderr.WriteString(StderrPrefix + line + "\n")
-                                       LogMutex.Unlock()
+                                       if StderrPrefix == "" {
+                                               withPrependedTgt(line)
+                                       } else {
+                                               stderrWrite(StderrPrefix + line + "\n")
+                                       }
                                        continue
                                }
                                if fdStderr != nil {
@@ -640,10 +644,13 @@ func runScript(tgt *Tgt, errs chan error, forced, traced bool) error {
                                if StderrSilent {
                                        continue
                                }
-                               if MyPid == 0 {
-                                       tracef(CNone, "%s", line)
+                               if MyPID != 0 {
+                                       line = pid + " " + line
+                               }
+                               if StderrPrefix == "" {
+                                       withPrependedTgt("[" + tgt.rel + "]" + line)
                                } else {
-                                       tracef(CNone, "%s %s", pid, line)
+                                       stderrWrite(StderrPrefix + "[" + tgt.rel + "]" + line + "\n")
                                }
                        }
                        close(stderrTerm)