diff --git a/src/os/exec_linux_test.go b/src/os/exec_linux_test.go index faa10b65..affd45a3 100644 --- a/src/os/exec_linux_test.go +++ b/src/os/exec_linux_test.go @@ -3,6 +3,7 @@ package os_test import ( + "errors" . "os" "runtime" "testing" @@ -17,8 +18,8 @@ func TestForkExec(t *testing.T) { return } - proc, err := StartProcess("echo", []string{"echo", "hello", "world"}, &ProcAttr{}) - if err != nil { + proc, err := StartProcess("/bin/echo", []string{"hello", "world"}, &ProcAttr{}) + if !errors.Is(err, nil) { t.Fatalf("forkExec failed: %v", err) return } diff --git a/src/os/osexec.go b/src/os/osexec.go index f92b796b..cf280fe8 100644 --- a/src/os/osexec.go +++ b/src/os/osexec.go @@ -14,7 +14,9 @@ func fork() (pid int, err error) { ret, _, err := syscall.Syscall(syscall.SYS_FORK, 0, 0, 0) if int(ret) != 0 { errno := err.(syscall.Errno) - return 0, errno + if int(errno) != 0 { + return -1, errno + } } return int(ret), nil }