Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
kevinburke opened this issue Oct 13, 2017 · 4 comments
Closed

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

kevinburke opened this issue Oct 13, 2017 · 4 comments

Comments

@kevinburke
Copy link
Contributor

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.)

@gopherbot
Copy link

Change https://golang.org/cl/74730 mentions this issue: os/signal: improve documentation for the Notify function

@bcmills
Copy link
Contributor

bcmills commented Oct 31, 2017

I don't really understand how the proposed documentation relates to the code snippet you've provided as a use-case: what does the call to signal.Notify have to do with the subprocess?

@ianlancetaylor
Copy link
Contributor

@bcmills: @kevinburke wants to forward all signals from the parent process to the child process, so the first step is a way to find out when the parent process receives an arbitrary signal.

@kevinburke
Copy link
Contributor Author

kevinburke commented Oct 31, 2017 via email

@golang golang locked and limited conversation to collaborators Nov 1, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants
@kevinburke @ianlancetaylor @bcmills @gopherbot and others