Add remaining (sans spawn, testbench)

This commit is contained in:
2024-05-05 00:02:38 +05:30
parent 750c23e26e
commit 2dbd7ac062
6 changed files with 94 additions and 2 deletions

26
exec/exec.go Normal file
View File

@@ -0,0 +1,26 @@
package exec
import (
"fmt"
"os"
"os/exec"
"syscall"
)
func Exec() {
defer fmt.Println("defer println")
lsPath, err := exec.LookPath("ls")
if err != nil {
panic(err)
}
envs := os.Environ()
// Exec replaces currently running go program and doesn't seem to care for `defer`s either
execErr := syscall.Exec(lsPath, []string{"-l", "-a", "-h", "/"}, envs)
if execErr != nil {
panic(execErr)
}
fmt.Println("Stopping the program")
}