4 ms·
Can you not use std::condition_variable to avoid the active waiting of the signal?
Can you not use std::condition_variable to avoid the active waiting of the signal?
signalfd or ppoll or a million other options
I don't know if std::condition_variable is async-signal safe, but an easy fix is to replace the sleeping with pause(2). There's also sigwait(3), which wouldn't need a signal handler.