Skip to content

os/signal: document how to forward all signals #22257

@kevinburke

Description

@kevinburke

I'm writing a command line wrapper that sets some state in the world, starts a child process, waits for it to complete, and then unsets some state in the world.

So basically something like

doSomeStatefulThing()
cmd := exec.Command("subcmd", args...)
cmd.Stdin = os.Stdin
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
err := cmd.Run()
undoSomeStatefulThing()
return err

I missed the line in the signal.Notify docs that says

If no signals are provided, all incoming signals will be relayed to c. Otherwise, just the provided signals will.

It might be good to provide a second Example for Notify where the args... list is empty, for people who are silly like me and miss the doc.

(It might also be good if it was easier to set up a proxied command - it seems like it's easy to miss some of the steps involved in proxying through all FD's/signals in both directions.)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions