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: documentation clarification #67773

Closed
withinboredom opened this issue Jun 2, 2024 · 3 comments
Closed

os/signal: documentation clarification #67773

withinboredom opened this issue Jun 2, 2024 · 3 comments
Assignees
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. Documentation

Comments

@withinboredom
Copy link

Go version

1.23

Output of go env in your module/workspace:

N/A

What did you do?

The current documentation reads:

The non-Go code should not change the signal mask on any threads created by the Go runtime. If the non-Go code starts new threads of its own, it may set the signal mask as it pleases.

But it doesn't state the consequences for doing so or in what conditions it is safe to do so. For example:

func callC() {
  runtime.LockOSThread()
  C.methodThatEventuallyCallsBackToGo()
}

// later
go callC()

What exactly would happen to signal masks in this case? Further, is the documentation saying that only if non-go code starts threads, it can set the signal mask, or is it saying that only the children may set signal masks?

What did you see happen?

Confusing or missing documentation in regards to signal masks.

What did you expect to see?

More detail and clarification in regards to signal masks in non-go code.

@gopherbot gopherbot added compiler/runtime Issues related to the Go compiler and/or runtime. Documentation labels Jun 2, 2024
@ianlancetaylor
Copy link
Contributor

I don't think the docs should lock us into specific consequences. I'll change them to read

The non-Go code should not change the signal mask on any threads created by the Go runtime. If the non-Go code starts new threads itself, those threads may set the signal mask as they please.

@ianlancetaylor ianlancetaylor self-assigned this Jun 3, 2024
@gopherbot
Copy link
Contributor

Change https://go.dev/cl/589755 mentions this issue: os/signal: clarify that non-Go thread may change signal mask

@withinboredom
Copy link
Author

Thank you for the clarification @ianlancetaylor! That's really all I needed to know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. Documentation
Projects
None yet
Development

No branches or pull requests

3 participants