Skip to content

Fixing the improper type of sighandler_t on unix#4918

Open
ItshMoh wants to merge 5 commits intorust-lang:mainfrom
ItshMoh:sigaction
Open

Fixing the improper type of sighandler_t on unix#4918
ItshMoh wants to merge 5 commits intorust-lang:mainfrom
ItshMoh:sigaction

Conversation

@ItshMoh
Copy link

@ItshMoh ItshMoh commented Jan 7, 2026

Fixes: #1359

Continued from #2107

@ItshMoh
Copy link
Author

ItshMoh commented Jan 7, 2026

hey @tgross35 I have continued the PR #2107 , I have removed the custom Debug implementation since one already exists in macros.rs here.
Though in this Debug implementation we are not accessing the union field's values.

Could you please take a look at the PR and let me know if this approach looks good?

@xtqqczze
Copy link
Contributor

@ItshMoh you need to run cargo +nightly fmt

Also, please rebase to squash your commits, making sure you include the exact string below for correct attribution:

Co-authored-by: Bradley Landherr <12598313+landhb@users.noreply.github.com>

@JohnTitor
Copy link
Member

@ItshMoh Could you resolve above comment?
@rustbot author

@rustbot
Copy link
Collaborator

rustbot commented Feb 28, 2026

Reminder, once the PR becomes ready for a review, use @rustbot ready.

Comment on lines +49 to +50
pub sa_handler: Option<extern "C" fn(c_int) -> ()>,
pub sa_sigaction: Option<extern "C" fn(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you make these functions unsafe?

}
}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please delete these, we are avoiding adding more iffy trait impls (even though this one is reasonably sound)

pub type locale_t = *mut c_void;

s_no_extra_traits! {
pub union __c_anonymous_sigaction_handler{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't need to be a __c_anonymous type, it can just be union sighandler_t with no alias since we're exporting it this way anyway.

pub type locale_t = *mut c_void;

s_no_extra_traits! {
pub union __c_anonymous_sigaction_handler{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you also add a comment about what the variants are representing? The two function pointers come from source, the integer variant is needed since sentinel values that aren't function pointers are used.

(maybe there's a better name for default? I think raw may make more sense)

@tgross35
Copy link
Contributor

tgross35 commented Mar 2, 2026

I'm sort of thinking that maybe we should have a type indicating raw function pointers and have those in a two-variant union, rather than a three-variant union with Rust function pointers. Sketched some of this up at #4998, curious what you think @JohnTitor

@rustbot
Copy link
Collaborator

rustbot commented Mar 2, 2026

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sighandler_t has an incorrect type on most unix targets

5 participants