syscall: forkAndExecInChild

This commit is contained in:
xushiwei
2024-07-28 22:27:26 +08:00
parent 09b6b9259c
commit 3a8642b1e0
2 changed files with 3 additions and 8 deletions

18
_cmptest/osexec/exec.go Normal file
View File

@@ -0,0 +1,18 @@
package main
import (
"os"
"os/exec"
"runtime"
)
func main() {
ls := "ls"
if runtime.GOOS == "windows" {
ls = "dir"
}
cmd := exec.Command(ls)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
cmd.Run()
}