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

std.os.linux: remove app_mask and block&unblock pair in raise #22337

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ruihe774
Copy link
Contributor

I believe the order of first two u32 is wrong.

See also: https://github.com/bminor/musl/blob/master/src/signal/sigfillset.c

@alexrp
Copy link
Member

alexrp commented Dec 28, 2024

The reason musl special-cases SIGTIMER (32), SIGCANCEL (33), and SIGSYNCCALL (34) is that they're used in the implementation of pthread and timer APIs in musl.

The libc-less version of Zig's standard library does not use these signal numbers for anything, and the app_mask and all_mask constants are only used in the Linux implementations of raise() and abort() in std.posix when libc is not linked.

I'm inclined to say that, rather than adjusting app_mask, it should just be deleted in favor of using all_mask in raise() instead. But maybe there's some factor I'm missing here. cc @andrewrk since these constants were added in 6f1a7a0.

@ruihe774
Copy link
Contributor Author

I'm wondering why raise() need to block and unblock signals. musl does this, but glibc does not. I think we can remove the block&unblock pair.

@ruihe774 ruihe774 changed the title std.os.linux: fix value of app_mask std.os.linux: remove app_mask and block&unblock pair in raise Dec 31, 2024
@alexrp
Copy link
Member

alexrp commented Dec 31, 2024

musl does this, but glibc does not. I think we can remove the block&unblock pair.

Maybe. I'd still like Andrew's thoughts on this before we go ahead with that change.

@alexrp
Copy link
Member

alexrp commented Dec 31, 2024

Also, perhaps the same would be true of abort()?

@ruihe774
Copy link
Contributor Author

ruihe774 commented Dec 31, 2024

Also, perhaps the same would be true of abort()?

Current implementation of abort() first uses raise() then goes through the block/unblock pair. I guess in most cases (no user-installed handler) the process will just terminate at the first raise(). If it is not, it is necessary to use the block/unblock pair and reset the signal handler when all signals are blocked to avoid race condition.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants