@@ -29,6 +29,8 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/goplus/llgo/internal/lib/internal/syscall/execenv"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Error is returned by LookPath when it fails to classify a file as an
|
// Error is returned by LookPath when it fails to classify a file as an
|
||||||
@@ -1089,7 +1091,6 @@ func minInt(a, b int) int {
|
|||||||
// would be run as it is currently configured. If an error occurs in computing
|
// would be run as it is currently configured. If an error occurs in computing
|
||||||
// the environment, it is returned alongside the best-effort copy.
|
// the environment, it is returned alongside the best-effort copy.
|
||||||
func (c *Cmd) environ() ([]string, error) {
|
func (c *Cmd) environ() ([]string, error) {
|
||||||
/* TODO(xsw):
|
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
env := c.Env
|
env := c.Env
|
||||||
@@ -1128,8 +1129,6 @@ func (c *Cmd) environ() ([]string, error) {
|
|||||||
err = dedupErr
|
err = dedupErr
|
||||||
}
|
}
|
||||||
return addCriticalEnv(env), err
|
return addCriticalEnv(env), err
|
||||||
*/
|
|
||||||
panic("todo: exec.Cmd.environ")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Environ returns a copy of the environment in which the command would be run
|
// Environ returns a copy of the environment in which the command would be run
|
||||||
|
|||||||
@@ -16,13 +16,10 @@ import (
|
|||||||
// be canceled and return immediately with an ErrClosed error.
|
// be canceled and return immediately with an ErrClosed error.
|
||||||
// Close will return an error if it has already been called.
|
// Close will return an error if it has already been called.
|
||||||
func (f *File) Close() error {
|
func (f *File) Close() error {
|
||||||
/*
|
if f == nil {
|
||||||
if f == nil {
|
return ErrInvalid
|
||||||
return ErrInvalid
|
}
|
||||||
}
|
return f.close()
|
||||||
return f.file.close()
|
|
||||||
*/
|
|
||||||
panic("todo: os.(*File).Close")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// pread reads len(b) bytes from the File starting at byte offset off.
|
// pread reads len(b) bytes from the File starting at byte offset off.
|
||||||
|
|||||||
@@ -250,6 +250,27 @@ func openFileNolog(name string, flag int, perm FileMode) (*File, error) {
|
|||||||
return f, nil
|
return f, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (file *File) close() error {
|
||||||
|
return syscall.Close(int(file.fd))
|
||||||
|
/* TODO(xsw):
|
||||||
|
if file.dirinfo != nil {
|
||||||
|
file.dirinfo.close()
|
||||||
|
file.dirinfo = nil
|
||||||
|
}
|
||||||
|
var err error
|
||||||
|
if e := file.pfd.Close(); e != nil {
|
||||||
|
if e == poll.ErrFileClosing {
|
||||||
|
e = ErrClosed
|
||||||
|
}
|
||||||
|
err = &PathError{Op: "close", Path: file.name, Err: e}
|
||||||
|
}
|
||||||
|
|
||||||
|
// no need for a finalizer anymore
|
||||||
|
runtime.SetFinalizer(file, nil)
|
||||||
|
return err
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
func tempDir() string {
|
func tempDir() string {
|
||||||
dir := Getenv("TMPDIR")
|
dir := Getenv("TMPDIR")
|
||||||
if dir == "" {
|
if dir == "" {
|
||||||
|
|||||||
@@ -261,22 +261,17 @@ func forkAndExecInChild(argv0 *c.Char, argv, envv **c.Char, chroot, dir *c.Char,
|
|||||||
if fd[i] == i {
|
if fd[i] == i {
|
||||||
// dup2(i, i) won't clear close-on-exec flag on Linux,
|
// dup2(i, i) won't clear close-on-exec flag on Linux,
|
||||||
// probably not elsewhere either.
|
// probably not elsewhere either.
|
||||||
ret := os.Fcntl(c.Int(fd[i]), syscall.F_SETFD, 0)
|
if ret := os.Fcntl(c.Int(fd[i]), syscall.F_SETFD, 0); ret != 0 {
|
||||||
if ret != 0 {
|
|
||||||
err1 = Errno(ret)
|
err1 = Errno(ret)
|
||||||
goto childerror
|
goto childerror
|
||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
/* TODO(xsw):
|
|
||||||
// The new fd is created NOT close-on-exec,
|
// The new fd is created NOT close-on-exec,
|
||||||
// which is exactly what we want.
|
if ret := os.Dup2(c.Int(fd[i]), c.Int(i)); ret != 0 {
|
||||||
_, _, err1 = rawSyscall(abi.FuncPCABI0(libc_dup2_trampoline), uintptr(fd[i]), uintptr(i), 0)
|
err1 = Errno(ret)
|
||||||
if err1 != 0 {
|
|
||||||
goto childerror
|
goto childerror
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
panic("todo: syscall.forkAndExecInChild - dup2")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// By convention, we don't close-on-exec the fds we are
|
// By convention, we don't close-on-exec the fds we are
|
||||||
|
|||||||
Reference in New Issue
Block a user