[support.signal]

# 17 Language support library [[support]](./#support)

## 17.14 Other runtime support [[support.runtime]](support.runtime#support.signal)

### 17.14.5 Signal handlers [support.signal]

[1](#1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6491)

A call to the function signal synchronizes with any resulting
invocation of the signal handler so installed[.](#1.sentence-1)

[2](#2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6495)

A [*plain lock-free atomic operation*](#def:plain_lock-free_atomic_operation "17.14.5 Signal handlers [support.signal]") is
an invocation of a function f from [[atomics]](atomics "32.5 Atomic operations"),
such that:

- [(2.1)](#2.1)

f is the function atomic_is_lock_free(), or

- [(2.2)](#2.2)

f is the member function is_lock_free(), or

- [(2.3)](#2.3)

f is a non-static member function of class atomic_flag, or

- [(2.4)](#2.4)

f is a non-member function, and
the first parameter of f has type cv atomic_flag*, or

- [(2.5)](#2.5)

f is a non-static member function invoked on an object A,
such that A.is_lock_free() yields true, or

- [(2.6)](#2.6)

f is a non-member function, and
for every pointer-to-atomic argument A passed to f,atomic_is_lock_free(A) yields true[.](#2.sentence-1)

[3](#3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6523)

An evaluation is [*signal-safe*](#def:evaluation,signal-safe "17.14.5 Signal handlers [support.signal]") unless it includes one of the following:

- [(3.1)](#3.1)

a call to any standard library function,
except for plain lock-free atomic operations and
functions explicitly identified as signal-safe;
  [*Note [1](#note-1)*:
  This implicitly excludes the use of new and delete expressions
that rely on a library-provided memory allocator[.](#3.1.sentence-1)
 â *end note*]

- [(3.2)](#3.2)

an access to an object with thread storage duration;

- [(3.3)](#3.3)

a dynamic_cast expression;

- [(3.4)](#3.4)

throwing of an exception;

- [(3.5)](#3.5)

control entering a [*try-block*](except.pre#nt:try-block "14.1 Preamble [except.pre]") or [*function-try-block*](except.pre#nt:function-try-block "14.1 Preamble [except.pre]");

- [(3.6)](#3.6)

initialization of a variable with static storage duration
requiring dynamic initialization ([[basic.start.dynamic]](basic.start.dynamic "6.10.3.3 Dynamic initialization of non-block variables"), [[stmt.dcl]](stmt.dcl "8.10 Declaration statement"))[191](#footnote-191 "Such initialization can occur because it is the first odr-use ([term.odr.use]) of that variable.") ; or

- [(3.7)](#3.7)

waiting for the completion of the initialization of a variable with static storage duration ([[stmt.dcl]](stmt.dcl "8.10 Declaration statement"))[.](#3.sentence-1)

A signal handler invocation has undefined behavior if it includes
an evaluation that is not signal-safe[.](#3.sentence-2)

[4](#4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6563)

The function signal is signal-safe if it is invoked
with the first argument equal to the signal number
corresponding to the signal that caused the invocation of the handler[.](#4.sentence-1)

See also: ISO/IEC 9899:2024, 7.14

[191)](#footnote-191)[191)](#footnoteref-191)

Such initialization can occur because it is the first odr-use ([[basic.def.odr]](basic.def.odr#term.odr.use "6.3 One-definition rule")) of that variable[.](#footnote-191.sentence-1)
