#include "sys_defs.h"
#include <sys/time.h>
#include <unistd.h>
#include <errno.h>
#ifdef USE_SYS_SELECT_H
#include <sys/select.h>
#endif
#include <msg.h>
#include <iostuff.h>
void doze(unsigned delay)
{
struct timeval tv;
#define MILLION 1000000
tv.tv_sec = delay / MILLION;
tv.tv_usec = delay % MILLION;
while (select(0, (fd_set *) 0, (fd_set *) 0, (fd_set *) 0, &tv) < 0)
if (errno != EINTR)
msg_fatal("doze: select: %m");
}
#ifdef TEST
#include <stdlib.h>
int main(int argc, char **argv)
{
unsigned delay;
if (argc != 2 || (delay = atol(argv[1])) == 0)
msg_fatal("usage: %s microseconds", argv[0]);
doze(delay);
exit(0);
}
#endif