library: fmt.(*pp).doPrint; syscall.forkAndExecInChild
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"runtime"
|
"runtime"
|
||||||
@@ -15,4 +16,7 @@ func main() {
|
|||||||
cmd.Stdout = os.Stdout
|
cmd.Stdout = os.Stdout
|
||||||
cmd.Stderr = os.Stderr
|
cmd.Stderr = os.Stderr
|
||||||
cmd.Run()
|
cmd.Run()
|
||||||
|
|
||||||
|
output, _ := exec.Command(ls).Output()
|
||||||
|
fmt.Print(string(output))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1218,19 +1218,16 @@ formatLoop:
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (p *pp) doPrint(a []any) {
|
func (p *pp) doPrint(a []any) {
|
||||||
/*
|
prevString := false
|
||||||
prevString := false
|
for argNum, arg := range a {
|
||||||
for argNum, arg := range a {
|
isString := arg != nil && reflect.TypeOf(arg).Kind() == reflect.String
|
||||||
isString := arg != nil && reflect.TypeOf(arg).Kind() == reflect.String
|
// Add a space between two non-string arguments.
|
||||||
// Add a space between two non-string arguments.
|
if argNum > 0 && !isString && !prevString {
|
||||||
if argNum > 0 && !isString && !prevString {
|
p.buf.writeByte(' ')
|
||||||
p.buf.writeByte(' ')
|
|
||||||
}
|
|
||||||
p.printArg(arg, 'v')
|
|
||||||
prevString = isString
|
|
||||||
}
|
}
|
||||||
*/
|
p.printArg(arg, 'v')
|
||||||
panic("todo: fmt.(*pp).doPrint")
|
prevString = isString
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// doPrintln is like doPrint but always adds a space between arguments
|
// doPrintln is like doPrint but always adds a space between arguments
|
||||||
|
|||||||
@@ -7,6 +7,8 @@
|
|||||||
package syscall
|
package syscall
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"unsafe"
|
||||||
|
|
||||||
"github.com/goplus/llgo/c"
|
"github.com/goplus/llgo/c"
|
||||||
"github.com/goplus/llgo/c/os"
|
"github.com/goplus/llgo/c/os"
|
||||||
"github.com/goplus/llgo/c/syscall"
|
"github.com/goplus/llgo/c/syscall"
|
||||||
@@ -322,12 +324,9 @@ func forkAndExecInChild(argv0 *c.Char, argv, envv **c.Char, chroot, dir *c.Char,
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
childerror:
|
childerror:
|
||||||
/* TODO(xsw):
|
|
||||||
// send error code on pipe
|
// send error code on pipe
|
||||||
rawSyscall(abi.FuncPCABI0(libc_write_trampoline), uintptr(pipe), uintptr(unsafe.Pointer(&err1)), unsafe.Sizeof(err1))
|
os.Write(c.Int(pipe), unsafe.Pointer(&err1), unsafe.Sizeof(err1))
|
||||||
for {
|
for {
|
||||||
rawSyscall(abi.FuncPCABI0(libc_exit_trampoline), 253, 0, 0)
|
os.Exit(253)
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
panic("todo: syscall.forkAndExecInChild - childerror")
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user