Feb 9, 2022

[C++] what are allowed/no allowed in signal handler in C++17 (based on C11)

not allowed in signal handlers

  • Calling any standard library function (unless explicitly specified as signal-safe)
  • Calling new or delete (unless a safe memory allocator is used)
  • Using objects that are thread_local
  • Using dynamic_cast
  • Throwing an exception or entering a try block
  • Performing or waiting for the first initialization of a variable with static storage duration

allowed in signal handlers

  • abort() and _Exit()
  • quick_exit(), if the functions registered with at_quick_exit() are signal-safe
  • memcpy() and memmove()
  • All member functions of std::numeric_limits<>
  • All functions for std::initializer_lists
  • All type traits

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.