FAQ
I might be missing something (probably something Deep and True about how
unix processes and signals work) but:

```
package main

import (
"fmt"
"os/exec"
"syscall"
)

func main() {
cmd := exec.Command("sleep", "1000000")
cmd.Start()

done := make(chan struct{})
go func() {
err := cmd.Wait()
exitStatus := cmd.ProcessState.Sys().(syscall.WaitStatus).ExitStatus()

fmt.Println("Error:", err)
fmt.Println("Status:", exitStatus)

close(done)
}()

cmd.Process.Kill()

<-done
}
```

Outputs:
Error: signal: killed
Status: -1

Looking at ExitStatus here
(http://golang.org/src/pkg/syscall/syscall_linux.go?s=4510:4546#L180) I see
that -1 implies the process has not exited. But it actually has (I checked
with `ps`)!

Is this a bug, or desired behavior? When I run `sleep 1000000` in a shell
and then send said process the KILL signal I get an exit code of 137 which
is consistent with http://www.tldp.org/LDP/abs/html/exitcodes.html

Thanks!

Onsi

--
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.

Search Discussions

  • Tamás Gulácsi at Apr 29, 2014 at 4:19 am
    Please check your errors! Esp. cmd.Start()

    Are you sure you have an executable named sleep?

    --
    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.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedApr 29, '14 at 12:13a
activeApr 29, '14 at 4:19a
posts2
users2
websitegolang.org

2 users in discussion

Tamás Gulácsi: 1 post Onsi Fakhouri: 1 post

People

Translate

site design / logo © 2022 Grokbase