talk session
Paul Falstad
pfalstad at phoenix.princeton.edu
Fri May 10 18:56:52 AEST 1991
natha at hal.com (Nathaniel Ingersol) wrote:
>In article <1489 at cvbnetPrime.COM> mkaminsk at cvbnet.prime.com (mailhost) writes:
>:
>:Actually usleep(3) is going away in System V Release 4 (SVr4)
>:so you can use select(2):
>:
>: #include <stdio.h>
>: #include <sys/types.h>
>: #include <sys/time.h>
>:
>: struct timeval timeout;
>:
>: timeout.tv_sec = 0;
>: timeout.tv_usec = number_of_microseconds;
>:
>: /* call select for it's timeout feature */
>: select(1, NULL, NULL, NULL, &timeout);
>:
>
>Am I missing something here, or why can't you just make a usleep out
>of setitimer? You could even use ITIMER_REAL.
You could just do this, yes.
---
#include <sys/time.h>
#include <signal.h>
#include <stdio.h>
int handler(){;} /* needed to make pause() work */
usleep(unsigned usec) {
struct itimerval ix;
ix.it_value.tv_sec = 0;
ix.it_value.tv_usec = usec;
ix.it_interval.tv_sec = 0;
ix.it_interval.tv_usec = 0;
signal(SIGALRM,handler);
setitimer(ITIMER_REAL,&ix,NULL);
pause();
signal(SIGALRM,SIG_DFL);
}
---
Looks harder to me. :-)
--
Paul Falstad pfalstad at phoenix.princeton.edu
And on the roads, too, vicious gangs of KEEP LEFT signs!
If Princeton knew my opinions, they'd have expelled me long ago.
More information about the Comp.unix.questions
mailing list