From 3d10773e26167066ddc173dfe017e4fe06ba060e Mon Sep 17 00:00:00 2001 From: leongross Date: Mon, 29 Jul 2024 10:56:38 +0200 Subject: [PATCH] fix exec_other signature, fix syscall return vlaues Signed-off-by: leongross --- src/os/exec_other.go | 4 ++-- src/os/exec_posix.go | 8 ++++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/os/exec_other.go b/src/os/exec_other.go index 52acb33e39..6f699f39f5 100644 --- a/src/os/exec_other.go +++ b/src/os/exec_other.go @@ -7,6 +7,6 @@ func forkExec(argv0 string, argv []string, attr *ProcAttr) (pid int, err error) return 0, ErrNotImplemented } -func startProcess(argv0 string, argv []string, attr *ProcAttr) (pid int, handle uintptr, err error) { - return 0, 0, ErrNotImplemented +func startProcess(argv0 string, argv []string, attr *ProcAttr) (proc *Process, err error) { + return &Process{Pid: 0}, ErrNotImplemented } diff --git a/src/os/exec_posix.go b/src/os/exec_posix.go index ed8e6e84a1..8d5c7245a3 100644 --- a/src/os/exec_posix.go +++ b/src/os/exec_posix.go @@ -75,13 +75,17 @@ func forkExec(argv0 string, argv []string, attr *ProcAttr) (pid int, err error) argvp[0] = argv0p } - ret, _, _ = syscall.Fork() + pid = syscall.Fork() + if ret < 0 { + return 0, errors.New("fork failed") + } + if ret != 0 { // if fd == 0 code runs in parent return int(ret), nil } else { // else code runs in child, which then should exec the new process - ret, _, _ = syscall.Execve(argv0, argv, envp) + ret = syscall.Execve(argv0, argv, envp) if ret != 0 { // exec failed syscall.Exit(1)