Skip to content

fork/exec broken pipe #31157

Closed
Closed
@cxpbbs

Description

@cxpbbs

What version of Go are you using (go version)?

$ go version
1.7.3

Does this issue reproduce with the latest release?

Can't reproduce

What operating system and processor architecture are you using (go env)?

Linux 3.10.0-327.36.58.4.x86_64 #1 SMP x86_64 GNU/Linux

go env Output
$ go env
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/root/gopath"
GORACE=""
GOROOT="/usr/lib/golang"
GOTOOLDIR="/usr/lib/golang/pkg/tool/linux_amd64"
GCCGO="/usr/bin/gccgo"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build779701576=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"
PKG_CONFIG="pkg-config"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"

What did you do?

Loop creation process:
for i := 0; i < 1000; i++ {
cmd[i] = exec.Command("sleep", "1")
err := cmd[i].Start()
if err != nil {
fmt.Println("start process error:", err)
os.Exit(2)
}
}
for i := 0; i < 1000; i++ {
err := cmd[i].Wait()
if err != nil {
fmt.Println("wait error:", err)
os.Exit(3)
}
}

What did you expect to see?

Successfully created 1000 processes

What did you see instead?

errmsg:
fork/exec:broken pipe:""

View the source code, found that the error code may be as follows:

  1. in func startProcess(name string, argv []string, attr *ProcAttr) (p *Process, err error):
    from: https://github.com/golang/go/blob/release-branch.go1.7/src/os/exec_posix.go +47
    pid, h, e := syscall.StartProcess(name, argv, sysattr)
    if e != nil {
    return nil, &PathError{"fork/exec", name, e}
    }

2)func forkExec(argv0 string, argv []string, attr *ProcAttr) (pid int, err error) maybe return epipe
from:https://github.com/golang/go/blob/release-branch.go1.7/src/syscall/exec_unix.go + 209

    Close(p[1])
n, err = readlen(p[0], (*byte)(unsafe.Pointer(&err1)), int(unsafe.Sizeof(err1)))
Close(p[0])
if err != nil || n != 0 {
	if n == int(unsafe.Sizeof(err1)) {
		err = Errno(err1)
	}
	if err == nil {
		err = EPIPE   //The error can happen here
	}

	// Child failed; wait for it to exit, to make sure
	// the zombies don't accumulate.
	_, err1 := Wait4(pid, &wstatus, 0, nil)
	for err1 == EINTR {
		_, err1 = Wait4(pid, &wstatus, 0, nil)
	}
	return 0, err
}

// Read got EOF, so pipe closed on exec, so exec succeeded.
return pid, nil

Now I can't reproduce the error. Can you tell me what scenes might return this error when reading pipe?

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeWaitingForInfoIssue is not actionable because of missing required information, which needs to be provided.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions