Skip to content

Opt-out of signal handling #1212

@MarcoPolo

Description

@MarcoPolo

Is your feature request related to a problem? Please describe.

A user can't make use of the default behavior of signals in Go programs because we always register signal handlers.

I would like to use the app lifecycle without it registering a signal handler.

Describe the solution you'd like
A clear and concise description of what you want to happen.

  • Add an Option to App that opts-out of registering the signal receiver.

This should be an easy change:

  1. Add an option that sets signalReceivers.{notify,stopNotify} to no-ops.
  2. Add docs around option.

Happy to add once their's consensus.

Describe alternatives you've considered

I use fx as part of my library go-libp2p. An alternative is to expose the app.Done in my constructed object and let the user handle the signal explicitly this way. The problem with this approach is that it changes the standard way signal handling works in Go. User's should just concern themselves with signal.Notify rather than having to know that app.Done has registered a signal handler for them. And if the user hasn't registered with signal.Notify they would expect the default behavior from Go.

Is this a breaking change?
We do not accept breaking changes to the existing API. Please consider if your proposed solution is backwards compatible. If not, we can help you make it backwards compatible, but this must be considered when we consider new features.

No. It can be provided as an option. The default can remain the same.

Additional context

See related issues in go-libp2p:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions