4 ms·
pause() is fine, as long as you don't do it conditionally.
by Arch-TK 3y ago
pause() is fine, as long as you don't do it conditionally.
- ajross 3y agoWhat's a "non-conditional" pause though? Doing it in a main loop is still adjacent to a "while(something_to_do)" which isn't synchronized. I mean, yes, there are circumstances where you don't need a full condition variable. But those tend to be fragile and not subject to "just follow this one rule" design principles, and so should be avoided. Broadly I stand by the point: pause() as designed was a mistake and you shouldn't touch it. If you want signals to integrate into your main loop use signalfd() instead.
- Arch-TK 3y agoIf everything you wish to achieve in response to a signal can be achieved within the signal handler, you do not need a condition. Just `while (1) pause();`. Granted, this isn't a very common situation, but I can imagine a few use-cases.