Source File
exec_unix.go
Belonging Package
syscall
package syscall
import (
errorspkg
)
func ( []string) ([]*byte, error) {
:= 0
for , := range {
if bytealg.IndexByteString(, 0) != -1 {
return nil, EINVAL
}
+= len() + 1 // +1 for NUL
}
:= make([]*byte, len()+1)
:= make([]byte, )
= 0
for , := range {
[] = &[]
copy([:], )
+= len() + 1
}
return , nil
}
func ( int) { fcntl(, F_SETFD, FD_CLOEXEC) }
func ( int, bool) ( error) {
, := fcntl(, F_GETFL, 0)
if != nil {
return
}
if {
|= O_NONBLOCK
} else {
&^= O_NONBLOCK
}
_, = fcntl(, F_SETFL, )
return
}
type Credential struct {
Uid uint32 // User ID.
Gid uint32 // Group ID.
Groups []uint32 // Supplementary group IDs.
NoSetGroups bool // If true, don't set supplementary groups
}
type ProcAttr struct {
Dir string // Current working directory.
Env []string // Environment.
Files []uintptr // File descriptors.
Sys *SysProcAttr
}
var zeroProcAttr ProcAttr
var zeroSysProcAttr SysProcAttr
func ( string, []string, *ProcAttr) ( int, error) {
var [2]int
var int
var Errno
var WaitStatus
if == nil {
= &zeroProcAttr
}
:= .Sys
if == nil {
= &zeroSysProcAttr
}
[0] = -1
[1] = -1
, := BytePtrFromString()
if != nil {
return 0,
}
, := SlicePtrFromStrings()
if != nil {
return 0,
}
, := SlicePtrFromStrings(.Env)
if != nil {
return 0,
}
if (runtime.GOOS == "freebsd" || runtime.GOOS == "dragonfly") && len([0]) > len() {
[0] =
}
var *byte
if .Chroot != "" {
, = BytePtrFromString(.Chroot)
if != nil {
return 0,
}
}
var *byte
if .Dir != "" {
, = BytePtrFromString(.Dir)
if != nil {
return 0,
}
}
if = forkExecPipe([:]); != nil {
goto
}
, = forkAndExecInChild(, , , , , , , [1])
if != 0 {
= Errno()
goto
}
ForkLock.Unlock()
func ()
func ()
var execveLibc func(path uintptr, argv uintptr, envp uintptr) Errno
var execveDarwin func(path *byte, argv **byte, envp **byte) error
var execveOpenBSD func(path *byte, argv **byte, envp **byte) error
func ( string, []string, []string) ( error) {
, := BytePtrFromString()
if != nil {
return
}
, := SlicePtrFromStrings()
if != nil {
return
}
, := SlicePtrFromStrings()
if != nil {
return
}
runtime_BeforeExec()
var error
= execveDarwin(, &[0], &[0])
= execveOpenBSD(, &[0], &[0])
} else {
_, _, = RawSyscall(SYS_EXECVE,
uintptr(unsafe.Pointer()),
uintptr(unsafe.Pointer(&[0])),
uintptr(unsafe.Pointer(&[0])))
}
runtime_AfterExec()
return
![]() |
The pages are generated with Golds v0.3.2-preview. (GOOS=darwin GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |