std::sig_atomic_t(3)

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

πŸ’– NAME πŸ’–

Bestie, welcome to std::sig_atomic_t(3) from the C++ Standard Libary β€” and the NAME line is literally std::sig_atomic_t - std::sig_atomic_t, which is the most β€œI contain multitudes” thing ever. πŸ’…

✨ Synopsis ✨

First things first: it’s Defined in header <csignal>, so that’s where you go looking. πŸŽ€

typedef /* unspecified */ sig_atomic_t;

Okay so what is it? It’s an integer type that can be accessed as an atomic entity even in the presence of asynchronous interrupts made by signals. That’s the whole assignment, fr. πŸ”₯

πŸŽ€ Notes πŸŽ€

History lesson, but make it cute: until C++11, which introduced std::atomic and std::atomic_signal_fence, about the only thing a strictly conforming program could do in a signal handler was assign a value to a volatile static std::sig_atomic_t variable and promptly return. That’s it. That’s the move. No extra side quests. 😭

πŸ¦‹ See also πŸ¦‹

  • signal β€” sets a signal handler for particular signal (function)
  • atomic_signal_fence (C++11) β€” fence between a thread and a signal handler executed in the same thread (function)
  • C documentation for sig_atomic_t

That’s the whole page, bestie 🫢 source: http://cppreference.com Β· version/date: 2024.06.10 Β· mwah πŸ’‹

πŸ“¦ where this page comes from