|
Hein Meling |
at Jul 18, 2014 at 3:12 am
|
⇧ |
| |
Your solution seems to work when then parent process exits cleanly. But if
you do:
func main() {
cmd := exec.Command("sleep", "15")
cmd.Start()
time.Sleep(20 * time.Second)
}
And CTRL-C the parent process before it exits cleanly, then also the sleep
process goes away. Does the same happen to your monkey.sh process?
Moreover, my use case is actually somewhat more involved. That is, I would
like to do cmd.Wait() (from different goroutines), in order to monitor the
child processes, but I don't want the child processes to fail if the parent
fails.
:) Hein
On Thursday, July 17, 2014 7:04:25 PM UTC-7, Shawn Milochik wrote:On Thu, Jul 17, 2014 at 9:56 PM, Hein Meling <hein....@gmail.com
<javascript:>> wrote:
No, because if the go program (the parent) is killed, the children also
gets killed.
Hein :)
That doesn't seem to be the case.
package main
import (
"os/exec"
)
func main() {
cmd := exec.Command("/tmp/monkey.sh")
cmd.Start()
}
When I run that, with monkey.sh being a program that just appends text
to a file, it keeps running after the Go program exits. I can even run the
Go program multiple times and multiple instances of monkey.sh are running.
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit
https://groups.google.com/d/optout.