Skip to content

Commit 8442180

Browse files
committed
fix exec_other signature, fix syscall return vlaues, add exec_other
stubs Signed-off-by: leongross <[email protected]>
1 parent cb2f4c3 commit 8442180

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

src/os/exec_other.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,19 @@
33

44
package os
55

6-
func forkExec(argv0 string, argv []string, attr *ProcAttr) (pid int, err error) {
6+
func findProcess(pid int) (*Process, error) {
7+
return &Process{Pid: pid}, nil
8+
}
9+
10+
func (p *Process) release() error {
11+
p.Pid = -1
12+
return nil
13+
}
14+
15+
func forkExec(_ string, _ []string, _ *ProcAttr) (pid int, err error) {
716
return 0, ErrNotImplemented
817
}
918

10-
func startProcess(argv0 string, argv []string, attr *ProcAttr) (pid int, handle uintptr, err error) {
11-
return 0, 0, ErrNotImplemented
19+
func startProcess(_ string, _ []string, _ *ProcAttr) (proc *Process, err error) {
20+
return &Process{Pid: 0}, ErrNotImplemented
1221
}

src/os/exec_posix.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,17 @@ func forkExec(argv0 string, argv []string, attr *ProcAttr) (pid int, err error)
7575
argvp[0] = argv0p
7676
}
7777

78-
ret, _, _ = syscall.Fork()
78+
pid = syscall.Fork()
79+
if ret < 0 {
80+
return 0, errors.New("fork failed")
81+
}
82+
7983
if ret != 0 {
8084
// if fd == 0 code runs in parent
8185
return int(ret), nil
8286
} else {
8387
// else code runs in child, which then should exec the new process
84-
ret, _, _ = syscall.Execve(argv0, argv, envp)
88+
ret = syscall.Execve(argv0, argv, envp)
8589
if ret != 0 {
8690
// exec failed
8791
syscall.Exit(1)

0 commit comments

Comments
 (0)