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

Signal must be masked when it is delivered to a signal handler #9299

Merged
merged 1 commit into from May 17, 2023

Conversation

patacongo
Copy link
Contributor

Summary

Signal must be masked when it is delivered to a signal handler per:

https://pubs.opengroup.org/onlinepubs/007904875/functions/sigaction.html:

When a signal is caught by a signal-catching function installed by sigaction(), a new signal mask is calculated and installed for the duration of the signal-catching function (or until a call to either sigprocmask() or sigsuspend() is made). This mask is formed by taking the union of the current signal mask and the value of the sa_mask for the signal being delivered [XSI] [Option Start] unless SA_NODEFER or SA_RESETHAND is set, [Option End] and then including the signal being delivered. If and when the user's signal handler returns normally, the original signal mask is restored.

Any action queued for that signal while the signal is masked should be deferred. It should go into the group pending signal list and should not be processed until until the signal is unmasked (which should occur when the signal handler returns).

See Issue #9298

Impact

  • Follows POSIX more closely
  • Probably has little effect because sa_mask typically does mask the signal explicitly
  • Probably does not effect re-entrancy of the signal handler because that is protected by other means.

Testing

sim:ostest

Signal must be masked when it is delivered to a signal handler per:

https://pubs.opengroup.org/onlinepubs/007904875/functions/sigaction.html:

When a signal is caught by a signal-catching function installed by sigaction(), a new signal mask is calculated and installed for the duration of the signal-catching function (or until a call to either sigprocmask() or sigsuspend() is made). This mask is formed by taking the union of the current signal mask and the value of the sa_mask for the signal being delivered [XSI] [Option Start] unless SA_NODEFER or SA_RESETHAND is set, [Option End] and then including the signal being delivered. If and when the user's signal handler returns normally, the original signal mask is restored.

Any action queued for that signal while the signal is masked should be deferred. It should go into the group pending signal list and should not be processed until until the signal is unmasked (which should occur when the signal handler returns).
@patacongo
Copy link
Contributor Author

I believe that this is a correct and complete change as submitted. However, there are other unrelated issues that could make this unreliable. See #9300

@patacongo patacongo added bug Something isn't working Standards NuttX application interfaces must compy to standards labels May 17, 2023
@xiaoxiang781216 xiaoxiang781216 linked an issue May 17, 2023 that may be closed by this pull request
@xiaoxiang781216 xiaoxiang781216 merged commit 8cca30b into apache:master May 17, 2023
26 checks passed
@patacongo patacongo deleted the sigmask branch May 17, 2023 17:54
@jerpelea jerpelea added this to To-Add in Release Notes - 12.2.0 Jun 13, 2023
@jerpelea jerpelea moved this from To-Add to In Progress in Release Notes - 12.2.0 Jun 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Standards NuttX application interfaces must compy to standards
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

Signal must be masked when it is delivered to a signal handler
3 participants