c/os: fork/exec
This commit is contained in:
20
_demo/cexec/exec.go
Normal file
20
_demo/cexec/exec.go
Normal 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))
|
||||
}
|
||||
Reference in New Issue
Block a user