Skip to content

Commit

Permalink
close pipes after use (redundant but just in case)
Browse files Browse the repository at this point in the history
also fix typo in example
  • Loading branch information
Leon Tappe committed Feb 13, 2025
1 parent 598385b commit 4833944
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion examples/timestamps.d/timestamps.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ job "echoloop" {
]

stdout = "test.log"
stdout = "test_error.log"
stderr = "test_error.log"
enableTimestamps = true
}
4 changes: 3 additions & 1 deletion pkg/proc/basejob.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,13 @@ func (job *baseJob) startOnce(ctx context.Context, process chan<- *os.Process) e
if err != nil {
return fmt.Errorf("failed to create stdout pipe for process: %s", err.Error())
}
defer stdoutPipe.Close()

stderrPipe, _ := cmd.StderrPipe()
stderrPipe, err := cmd.StderrPipe()
if err != nil {
return fmt.Errorf("failed to create stderr pipe for process: %s", err.Error())
}
defer stderrPipe.Close()

go job.logWithTimestamp(stdoutPipe, job.stdout)
go job.logWithTimestamp(stderrPipe, job.stderr)
Expand Down

0 comments on commit 4833944

Please sign in to comment.