I found a strange problem in golang.The program executed by exec.Start()
will quit if the parent program is interrupt by the signal os.Interrupt,while the child program will NOT quit if the parent program exit normally.What's the difference between that two conditions?
For examples:
package main
import "fmt"
import "os"
import "time"
import "os/exec"
func main(){
cmd := exec.Command("sleep", "100000")
cmd.Env = os.Environ()
fmt.Println(cmd.Env)
cmd.Start()
time.Sleep(1e9*20)
return
}
In the later condition the parent of sleep 100000
will be the init process
after 20s if we didn't interrupt the main program.