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

Replace SIGFUNC by sighandler_t #278

Merged
merged 2 commits into from Apr 8, 2023
Merged

Conversation

olebole
Copy link
Member

@olebole olebole commented Apr 6, 2023

The global C type SIGFUNC was used of a generic signal handling function type. However, this was used for three incompatible function types:

  • C signal handlers (void (*)(int)), i.e. a function called with the signal number

  • C signal actions (void (*)(int, siginfo_t *, void *)), i.e. a function called with the signal number, additional signal information, and some payload,

  • IRAF signal handlers (void (*)(XINT *, XINT *)), i.e. a function called with a pointer to the signal number and a pointer to the next handler.

Replacing these with proper types leaves only the last case in zxwhen.c as a use for SIGFUNC. However, this type is not used outside of zxwhen.c. As IRAF/SPP doesn't generally support function prototypes, it doesn't make sense to have it exposed anymore.

Fixing this, a bug in zxwhen.c was discovered and fixed where the result of setsig() was compared to SIG_IGN

iraf/unix/os/zxwhen.c

Lines 225 to 227 in d057e31

if (setsig (uex, vvector) == (long) SIG_IGN) {
setsig (uex, SIG_IGN);
ignore_sigint++;

however setsig() only returns a the return status of sigaction() (0 on success)

iraf/unix/os/zxwhen.c

Lines 264 to 266 in d057e31

status = (long) sigaction (code, &sig, NULL);
return (status);

SIGFUNC is mainly used as a type handled by signal()
resp. sigaction(). This is all replaced by void (*)(int).

sighandler_t itself is a GNU extension which we do not use here for
better portability.

The only place where SIGFUNC is still there is one place zxwhen.c,
because here the call signature is different.
Make sure that sigactions and sighandlers are not intermixed.
@olebole olebole merged commit ad2fac5 into iraf-community:main Apr 8, 2023
3 checks passed
@olebole olebole deleted the sigfunc branch April 8, 2023 10:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant