Skip to content

os/signal: document signal behavior #9896

Closed
@ianlancetaylor

Description

@ianlancetaylor

Right now at process start up time on a Unix system all signals are caught, except that if SIGHUP and SIGINT are ignored, they remain ignored. If the program uses the os/signal.Notify to request notification of a signal, and then calls Stop, the signal will no longer be caught--it will revert to the default behaviour.

There are three states for a signal: caught, default, ignored. Right now we always start at caught, except for SIGHUP/SIGINT, and then os/signal can change to default. We should be more consistent about signal states. Or at least document it better.

Activity

added this to the Go1.5 milestone on Feb 16, 2015
alexbrainman

alexbrainman commented on Feb 16, 2015

@alexbrainman
Member

There are three states for a signal: caught, default, ignored. ...

Not on windows. Windows Ctrl+C cannot be ignored. By default Windows provides its own handler (print ^C and exit process), but you can override it with SetConsoleCtrlHandler. Of course you can provide your own Ctrl+C handler that does nothing.

Alex

ianlancetaylor

ianlancetaylor commented on Feb 17, 2015

@ianlancetaylor
ContributorAuthor

Thanks. I was perhaps less clear than I should have been that this issue is Unix-specific.

alexbrainman

alexbrainman commented on Feb 17, 2015

@alexbrainman
Member

Maybe this functionality should not be part of os/signal then. (I am not sure what happens on plan9). At the very least, we should be clear about this in the documentation.

changed the title [-]os/signal, runtime: init sets up signal handlers, Stop and Disable turn them off[/-] [+]os/signal, runtime: document signal states better[/+] on Jul 22, 2015
modified the milestones: Unplanned, Go1.5 on Jul 22, 2015
rsc

rsc commented on Nov 24, 2015

@rsc
Contributor

We need to document signal states but also other details. For example, what happens if C registers a signal handler and then Go does? What happens in the reverse order? Is it different for cgo vs c-shared? And so on.

These issues - in no particular order - are all about signals, and some would be cleared up by such docs (others are plain bugs):

changed the title [-]os/signal, runtime: document signal states better[/-] [+]os/signal: document signal behavior[/+] on Nov 24, 2015
modified the milestones: Go1.6, Unplanned on Nov 24, 2015
gopherbot

gopherbot commented on Dec 16, 2015

@gopherbot
Contributor

CL https://golang.org/cl/17877 mentions this issue.

4 remaining items

gopherbot

gopherbot commented on Dec 26, 2015

@gopherbot
Contributor

CL https://golang.org/cl/18150 mentions this issue.

gopherbot

gopherbot commented on Dec 28, 2015

@gopherbot
Contributor

CL https://golang.org/cl/18151 mentions this issue.

ianlancetaylor

ianlancetaylor commented on Jan 2, 2016

@ianlancetaylor
ContributorAuthor

Signal handling is now documented. All the issues mentioned above are either fixed, or have CLs out to fix them, except for #12516. We don't need two issues open for that problem, so closing this one.

gopherbot

gopherbot commented on Jan 7, 2016

@gopherbot
Contributor

CL https://golang.org/cl/18365 mentions this issue.

locked and limited conversation to collaborators on Jan 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @rsc@ianlancetaylor@gopherbot@alexbrainman

        Issue actions

          os/signal: document signal behavior · Issue #9896 · golang/go