1
0
mirror of https://github.com/gryf/wmaker.git synced 2025-12-19 20:38:08 +01:00
Files
wmaker/WINGs/usleep.c
Brad Jorsch c37046e6a9 Fix wusleep
struct timespec's tm_nsec is in nanoseconds, not microseconds.

Signed-off-by: Brad Jorsch <anomie@users.sourceforge.net>
2010-10-07 12:04:31 +02:00

26 lines
426 B
C

#include <errno.h>
#include <time.h>
#include "wconfig.h"
void wusleep(unsigned int usec)
{
struct timespec tm;
/* An arbitrary limit of 10 minutes -- in WM, if
* somethings wants to sleep anything even close to
* this, it's most likely an error.
*/
if (usec > 600000000)
return;
tm.tv_sec = usec / 1000000;
tm.tv_nsec = (usec % 1000000) * 1000;
while (nanosleep(&tm, &tm) == -1 && errno == EINTR)
;
}