std::raise(3)

πŸ“¦ version 2024.07.05, in nixpkgs unstable, opensuse-leap 16.0

🌸 NAME 🌸

std::raise - std::raise β€” yes bestie, the function is so nice they named it twice ✨. This page comes from the C++ Standard Libary (and yes, the header really spells it like that β€” iconic typo, no notes πŸ’€), and we’re about to send some signals, okay? πŸ’…


πŸ¦‹ Synopsis πŸ¦‹

Defined in header <csignal>
int raise( int sig );

Sends signal sig to the program. The signal handler β€” the one you specify with the std::signal() function β€” gets invoked. 🫢

If you haven’t set a user-defined signal handling strategy using std::signal() yet, it is implementation-defined whether the signal will be ignored or the default handler will be invoked. Like, the standard is literally not promising you which one, so don’t act surprised 😭.


πŸ’… Parameters πŸ’…

sig β€” the signal to be sent. It can be an implementation-defined value or one of the following values:

  • SIGABRT
  • SIGFPE
  • SIGILL
  • SIGINT
  • SIGSEGV
  • SIGTERM

These are macro constants that define signal types. Slay, constants πŸ’–.


✨ Return value ✨

0 upon success, non-zero value on failure. That’s it, that’s the vibe check πŸ”₯.


🌈 Example 🌈

// Run this code

#include <csignal>
#include <iostream>

void signal_handler(int signal)
{
    std::cout << "Received signal " << signal << '\n';
}

int main()
{
    // Install a signal handler
    std::signal(SIGTERM, signal_handler);

    std::cout << "Sending signal " << SIGTERM << '\n';
    std::raise(SIGTERM);
}

πŸ’– Possible output πŸ’–

Sending signal 15
Received signal 15

πŸŽ€ See also πŸŽ€

  • signal β€” sets a signal handler for particular signal (function)
  • C documentation for raise

source: http://cppreference.com Β· version/date: 2024.06.10 Β· std::raise(3) signing off, love u bestie πŸ’–πŸ«ΆπŸŽ€

πŸ“¦ where this page comes from