cppreference.com documents this function as \"fence between a thread and a signal handler executed in the same thread\". But I found no example on the Internet.
I wonder
In your example, you want to use std::atomic_thread_fence
(which generates machine code to perform thread synchronization); not std::atomic_signal_fence
(which only disables compiler memory reordering optimizations on atomic variables).
As was said by others, std::atomic_signal_fence
is only intended for signals on the same thread as the atomic operations (I believe it would also hold true for structured/vectored exception handlers on Windows, but don't quote me on that).