Skip to content

Commit

Permalink
fix exec_other signature, fix syscall return vlaues
Browse files Browse the repository at this point in the history
Signed-off-by: leongross <[email protected]>
  • Loading branch information
leongross committed Jul 29, 2024
1 parent cb2f4c3 commit 3d10773
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/os/exec_other.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
8 changes: 6 additions & 2 deletions src/os/exec_posix.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 3d10773

Please sign in to comment.