SIGINTERRUPT(3POSIX)

πŸ’– SIGINTERRUPT(3POSIX) β€” bestie edition πŸ’–

okay so this one's from the POSIX Programmer's Manual, and I'm gonna hold your hand through it, no gatekeeping. ✨

🌸 PROLOG 🌸

so like, real talk first: this manual page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ (so if you're on Linux, go read the corresponding Linux manual page for the actual tea on Linux behavior), or honestly the interface may not even be implemented on Linux at all. πŸ™ˆ Not me warning you before we even start.


✨ NAME ✨

siginterrupt β€” the function that lets signals interrupt functions. it's giving "let me interrupt you real quick" πŸ’…

πŸŽ€ SYNOPSIS πŸŽ€

#include <signal.h>

int siginterrupt(int sig, int flag);

πŸ’œ DESCRIPTION πŸ’œ

So siginterrupt() shall change the restart behavior when a function is interrupted by the specified signal. Like, when a signal shows up mid-function, do we restart the function or not? That's the whole vibe check.

The function siginterrupt(sig, flag) has an effect as if it were implemented exactly like this, and I need you to read every line because the details matter, bestie:

int siginterrupt(int sig, int flag) {
    int ret;
    struct sigaction act;

    (void) sigaction(sig, NULL, &act);
    if (flag)
        act.sa_flags &= ~SA_RESTART;
    else
        act.sa_flags |= SA_RESTART;
    ret = sigaction(sig, &act, NULL);
    return ret;
}

like. that's literally it. that's the whole thing. 🫢

⭐ RETURN VALUE ⭐

Upon successful completion, siginterrupt() shall return 0. Otherwise, -1 shall be returned and errno gets set to indicate the error. classic. 😭

πŸ”₯ ERRORS πŸ”₯

The siginterrupt() function shall fail if:

  • EINVAL β€” the sig argument is not a valid signal number. bestie. that's not a real signal. πŸ’€
The following sections are informative. (so like, the drama is over, these are just the extra notes πŸ‘‘)

🌈 EXAMPLES 🌈

None. yeah. there's just... nothing here. iconic of them honestly. πŸ“

πŸ¦‹ APPLICATION USAGE πŸ¦‹

The siginterrupt() function supports programs written to historical system interfaces. (vintage! nostalgic! a little crusty!)

Applications should use the sigaction() with the SA_RESTART flag instead of the obsolescent siginterrupt() function. so like, it's not broken, it's just old. use the new one, please, for me. πŸ™

πŸ’… RATIONALE πŸ’…

None. no thoughts, head empty, nothing to justify. ✨

🧚 FUTURE DIRECTIONS 🧚

None. it's just gonna keep existing like that. 🫠

🌟 SEE ALSO 🌟

  • Section 2.4, Signal Concepts
  • sigaction()
  • The Base Definitions volume of POSIX.1‐2017, <signal.h>

Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group.

In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. (they're the final boss, fr fr. don't argue with them.) The original Standard can be obtained online at http://www.opengroup.org/unix/online.html .

Any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. To report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html .


and that's a wrap, bestie!! this page was served up by IEEE/The Open Group, dated 2017, under the SIGINTERRUPT(3POSIX) banner πŸ’– go forth and interrupt responsibly βœ¨πŸ’…πŸŽ€