Skip to content

os/signal: Unable to catch SIGHUP signal multiple times #11700

@ghost

Description

I have the following code:

func HandleSIGHUP() chan os.Signal {
    sig := make(chan os.Signal, 1)

    signal.Notify(sig, syscall.SIGHUP)

    return sig
}

I "register" the signal like so:

go func() {
    for {
        <-HandleSIGHUP()

        // do something
    }
}()

The problem that I'm experiencing is that I'm only able to catch one SIGHUP. For example if I send multiple kill -SIGHUP <pid> to the process, the "register" code only runs once. How can I get it to run every time the signal is sent?

$ go version
go version go1.4.2 linux/amd64

I also posted this here: http://stackoverflow.com/questions/31395761/handle-signal-multiple-times-in-golang

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions