1 /* This file is part of the Project Athena Zephyr Notification System.
2 * It contains the ZCheckIfNotice/select loop used for waiting for
3 * a notice, with a timeout.
5 * Created by: <Joe Random Hacker>
9 * Copyright (c) 1991 by the Massachusetts Institute of Technology.
10 * For copying and distribution information, see the file
14 #include "mit-copyright.h"
17 static char rcsid_ZWaitForNotice_c[] = "$Id$";
21 #include <sys/socket.h>
24 Z_WaitForNotice(ZNotice_t *notice,
25 int (*pred) __P((ZNotice_t *, void *)),
30 struct timeval tv, t0;
34 retval = ZCheckIfNotice (notice, (struct sockaddr_in *) 0, pred,
36 if (retval == ZERR_NONE)
38 if (retval != ZERR_NONOTICE)
45 gettimeofday (&t0, (struct timezone *) 0);
49 i = select (fd + 1, &fdmask, (fd_set *) 0, (fd_set *) 0, &tv);
52 if (i < 0 && errno != EINTR)
55 retval = ZCheckIfNotice (notice, (struct sockaddr_in *) 0, pred,
57 if (retval != ZERR_NONOTICE) /* includes ZERR_NONE */
60 gettimeofday (&tv, (struct timezone *) 0);
61 tv.tv_usec = t0.tv_usec - tv.tv_usec;
63 tv.tv_usec += 1000000;
64 tv.tv_sec = t0.tv_sec - tv.tv_sec - 1;
67 tv.tv_sec = t0.tv_sec - tv.tv_sec;