Skip to content

x/sys/unix: add SignalNum() to convert signal name to a number #28027

@kolyshkin

Description

@kolyshkin

A SignalName() method was recently (#25134) added to x/sys/unix to convert a numeric signal id to a name. It uses signalList array which contains names and numeric values for all known signals on every platform.

This is a proposal to add a complementary method to convert a string representation to a number.

// SignalNum returns the syscall.Signal for signal named s,
// or an error if a signal with such name is not found.
func SignalNum(s string) (syscall.Signal, error)

For example, SignalNum("SIGTERM") is to return 15, nil, and it should probably do the same for SignalNum("TERM") and SignalNum("term").

Update: s/SignalId/SignalNum/

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions