c/os: fork/exec

This commit is contained in:
xushiwei
2024-07-12 00:39:16 +08:00
parent aac820a8d5
commit 11682e487e
12 changed files with 1083 additions and 25 deletions

20
_demo/cexec/exec.go Normal file
View File

@@ -0,0 +1,20 @@
package main
import (
"runtime"
"unsafe"
"github.com/goplus/llgo/c"
"github.com/goplus/llgo/c/os"
)
func main() {
ls := c.Str("ls")
args := []*c.Char{ls, c.Str("-l"), nil}
if runtime.GOOS == "windows" {
ls = c.Str("dir")
args = []*c.Char{ls, nil}
}
os.Execvp(ls, unsafe.SliceData(args))
}