Files
wmaker/WINGs/usleep.c
T

27 lines
445 B
C
Raw Normal View History

1998-09-29 22:36:29 +00:00
2010-09-29 02:52:19 +02:00
#include <errno.h>
#include <time.h>
1998-09-29 22:36:29 +00:00
#include "WUtil.h"
2010-09-29 02:52:19 +02:00
#include "wconfig.h"
1998-09-29 22:36:29 +00:00
2010-09-29 02:52:19 +02:00
void wusleep(unsigned int usec)
1998-09-29 22:36:29 +00:00
{
2010-09-29 02:52:19 +02:00
struct timespec tm;
1998-09-29 22:36:29 +00:00
2010-09-29 02:52:19 +02:00
/* 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;
1998-09-29 22:36:29 +00:00
2010-09-29 02:52:19 +02:00
tm.tv_sec = usec / 1000000;
2010-09-30 08:58:19 -04:00
tm.tv_nsec = (usec % 1000000) * 1000;
1998-09-29 22:36:29 +00:00
2010-09-29 02:52:19 +02:00
while (nanosleep(&tm, &tm) == -1 && errno == EINTR)
;
1998-09-29 22:36:29 +00:00
2010-09-29 02:52:19 +02:00
}
1998-09-29 22:36:29 +00:00