To avoid uncertainty about interrupting access to a variable, you can
use a particular data type for which access is always atomic:
sig_atomic_t. Reading and writing this data type is guaranteed
to happen in a single instruction, so there's no way for a handler to
run "in the middle" of an access.
sig_atomic_t is always an integer data type, but which
one it is, and how many bits it contains, may vary from machine to
In practice, you can assume that
int and other integer types no
int are atomic. You can also assume that pointer
types are atomic; that is very convenient. Both of these are true on
all of the machines that the GNU C library supports, and on all POSIX
systems we know of.
Go to the first, previous, next, last section, table of contents.