procs icon indicating copy to clipboard operation
procs copied to clipboard

Race condition on commands with pipes and an error

Open dlm opened this issue 4 months ago • 0 comments

Given the file main.go with contents:

package main

import "os"

func main() {
	os.Exit(1)
}

and the file main_test.go with contents:

package main_test

import (
        "testing"
        "github.com/ionrock/procs"
)

func TestIt(t *testing.T) {
        p := procs.NewProcess("echo 4 + 3 | go run main.go")

        if err := p.Start(); err != nil {
                t.Fatalf("running: %s", err.Error())
        }

        if err := p.Wait(); err != nil {
                t.Fatalf("running: %s", err.Error())
        }
}

When I run the command:

go test -race ./main_test.go

I receive an error that there is a race condition.

dlm avatar Oct 16 '24 20:10 dlm