Add remaining (sans spawn, testbench)
This commit is contained in:
26
exec/exec.go
Normal file
26
exec/exec.go
Normal 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")
|
||||
}
|
||||
Reference in New Issue
Block a user