Quellcode durchsuchen

fix: memory leak (#83)

Yeuoly vor 1 Jahr
Ursprung
Commit
ef193b1d8e
1 geänderte Dateien mit 2 neuen und 4 gelöschten Zeilen
  1. 2 4
      internal/core/runner/output_capture.go

+ 2 - 4
internal/core/runner/output_capture.go

@@ -56,16 +56,14 @@ func (s *OutputCaptureRunner) CaptureOutput(cmd *exec.Cmd) error {
 		timeout = 5 * time.Second
 	}
 
-	timer := time.NewTimer(timeout)
-	go func() {
-		<-timer.C
+	timer := time.AfterFunc(timeout, func() {
 		if cmd != nil && cmd.Process != nil {
 			// write the error
 			s.WriteError([]byte("error: timeout\n"))
 			// send a signal to the process
 			cmd.Process.Kill()
 		}
-	}()
+	})
 
 	// create a pipe for the stdout
 	stdout_reader, err := cmd.StdoutPipe()