Skip to content

Race condition on commands with pipes and an error #7

@dlm

Description

@dlm

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions