Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Replace current process

Tags:

process

go

In Ruby, you can use Kernel.exec to replace the current executing process by the one triggered.

Is it possible to do the same thing in Go?

like image 707
kolrie Avatar asked Jun 28 '13 01:06

kolrie


1 Answers

This is the equivalent to Kernel.exec:

package main

import "fmt"
import "syscall"

func main() {
    if err := syscall.Exec("/bin/ls", []string{"ls", "-l"}, []string{}); err != nil {
      fmt.Println(err)
    }
}

but it is not portable.

like image 116
perreal Avatar answered Oct 19 '22 10:10

perreal



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!