c/syscall: zerrors
This commit is contained in:
@@ -9,8 +9,11 @@
|
||||
package syscall
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"runtime"
|
||||
"sync"
|
||||
"syscall"
|
||||
"unsafe"
|
||||
|
||||
"github.com/goplus/llgo/c"
|
||||
"github.com/goplus/llgo/c/os"
|
||||
@@ -106,13 +109,10 @@ type ProcAttr struct {
|
||||
Sys *SysProcAttr
|
||||
}
|
||||
|
||||
/* TODO(xsw):
|
||||
var zeroProcAttr ProcAttr
|
||||
var zeroSysProcAttr SysProcAttr
|
||||
*/
|
||||
|
||||
func forkExec(argv0 string, argv []string, attr *ProcAttr) (pid int, err error) {
|
||||
/* TODO(xsw):
|
||||
var p [2]int
|
||||
var n int
|
||||
var err1 Errno
|
||||
@@ -127,45 +127,30 @@ func forkExec(argv0 string, argv []string, attr *ProcAttr) (pid int, err error)
|
||||
}
|
||||
|
||||
// Convert args to C form.
|
||||
argv0p, err := BytePtrFromString(argv0)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
argvp, err := SlicePtrFromStrings(argv)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
envvp, err := SlicePtrFromStrings(attr.Env)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
argv0p := c.AllocaCStr(argv0)
|
||||
argvp := c.AllocaCStrs(argv, true)
|
||||
envvp := c.AllocaCStrs(attr.Env, true)
|
||||
|
||||
if (runtime.GOOS == "freebsd" || runtime.GOOS == "dragonfly") && len(argv) > 0 && len(argv[0]) > len(argv0) {
|
||||
argvp[0] = argv0p
|
||||
*argvp = argv0p
|
||||
}
|
||||
|
||||
var chroot *byte
|
||||
var chroot *c.Char
|
||||
if sys.Chroot != "" {
|
||||
chroot, err = BytePtrFromString(sys.Chroot)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
chroot = c.AllocaCStr(sys.Chroot)
|
||||
}
|
||||
var dir *byte
|
||||
var dir *c.Char
|
||||
if attr.Dir != "" {
|
||||
dir, err = BytePtrFromString(attr.Dir)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
dir = c.AllocaCStr(attr.Dir)
|
||||
}
|
||||
|
||||
// Both Setctty and Foreground use the Ctty field,
|
||||
// but they give it slightly different meanings.
|
||||
if sys.Setctty && sys.Foreground {
|
||||
return 0, errorspkg.New("both Setctty and Foreground set in SysProcAttr")
|
||||
return 0, errors.New("both Setctty and Foreground set in SysProcAttr")
|
||||
}
|
||||
if sys.Setctty && sys.Ctty >= len(attr.Files) {
|
||||
return 0, errorspkg.New("Setctty set but Ctty not valid in child")
|
||||
return 0, errors.New("Setctty set but Ctty not valid in child")
|
||||
}
|
||||
|
||||
acquireForkLock()
|
||||
@@ -214,8 +199,6 @@ func forkExec(argv0 string, argv []string, attr *ProcAttr) (pid int, err error)
|
||||
|
||||
// Read got EOF, so pipe closed on exec, so exec succeeded.
|
||||
return pid, nil
|
||||
*/
|
||||
panic("todo: syscall.forkExec")
|
||||
}
|
||||
|
||||
// Combination of fork and exec, careful to be thread safe.
|
||||
|
||||
Reference in New Issue
Block a user