home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume25 / letters / usleep.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-01-02  |  615 b   |  26 lines

  1. /*
  2.  * I grabbed this from the FAQ liston comp.unix.questions
  3.  */
  4. /*
  5.  * usleep -- support routine for 4.2BSD system call emulations
  6.  * 
  7.  * last edit:    29-Oct-1984    D A Gwyn
  8.  */
  9.  
  10. extern int      select();
  11.  
  12.  
  13. int             usleep(usec)    /* returns 0 if ok, else -1 */
  14. long            usec;        /* delay in microseconds */
  15. {
  16.     static struct {        /* `timeval' */
  17.         long            tv_sec;    /* seconds */
  18.         long            tv_usec;    /* microsecs */
  19.     }               delay;    /* _select() timeout */
  20.  
  21.     delay.tv_sec = usec / 1000000L;
  22.     delay.tv_usec = usec % 1000000L;
  23.  
  24.     return select(0, (long *) 0, (long *) 0, (long *) 0, &delay);
  25. }
  26.