Skip to content

Commit b4952ad

Browse files
committed
renaming
1 parent afd54b8 commit b4952ad

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

src/os/exec.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ type Process struct {
6262
}
6363

6464
func StartProcess(name string, argv []string, attr *ProcAttr) (*Process, error) {
65-
return nil, &PathError{Op: "fork/exec", Path: name, Err: ErrNotImplemented}
65+
return startProcess(name, argv, attr)
6666
}
6767

6868
func (p *Process) Wait() (*ProcessState, error) {

src/os/exec_linux.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -75,20 +75,20 @@ func forkExec(argv0 string, argv []string, attr *ProcAttr) (pid int, err error)
7575
argvp[0] = argv0p
7676
}
7777

78-
pid = syscall.Fork()
79-
if ret < 0 {
78+
ret = syscall.Fork()
79+
if int(ret) < 0 {
8080
return 0, errors.New("fork failed")
8181
}
8282

83-
if ret != 0 {
83+
if int(ret) != 0 {
8484
// if fd == 0 code runs in parent
8585
return int(ret), nil
8686
} else {
8787
// else code runs in child, which then should exec the new process
8888
ret = syscall.Execve(argv0, argv, envp)
89-
if ret != 0 {
89+
if int(ret) != 0 {
9090
// exec failed
91-
syscall.Exit(1)
91+
return int(ret), errors.New("exec failed")
9292
}
9393
// 3. TODO: use pipes to communicate back child status
9494
return int(ret), nil
@@ -101,7 +101,7 @@ func forkExec(argv0 string, argv []string, attr *ProcAttr) (pid int, err error)
101101
// The StartProcess function creates a new process by forking the current process and then calling execve to replace the current process with the new process.
102102
// It thereby replaces the newly created process with the specified command and arguments.
103103
func startProcess(name string, argv []string, attr *ProcAttr) (p *Process, err error) {
104-
pid, err := ForkExec(name, argv, attr)
104+
pid, err := forkExec(name, argv, attr)
105105
if err != nil {
106106
return nil, err
107107
}
File renamed without changes.

0 commit comments

Comments
 (0)