sub-second sleeps on BSD 4.2

Stanley Friesen friesen at psivax.UUCP
Tue Apr 23 03:50:09 AEST 1985


	I am having trouble in writing a routine to handle less than
one second sleeps on BSD 4.2 using setitimer and sigpause. The routine
I am using is similar to the code for sleep().  My problem, it keeps
hanging sfter a random number of calls. It seems that eventually it
does not return from sigpause. Why? What can I do about it?
The code is as follows:

#include <sys/time.h> 
#include <signal.h>

int wakeup;

void nullfunc(){
    wakeup = 1;
}

struct itimerval tm = {{0, 0}, {0, 1500}};

delay()
{

    void nullfunc();

    signal(SIGALRM, nullfunc);
    wakeup = 0;
    if(setitimer(ITIMER_REAL, &tm, NULL)) exit(1);
    while(wakeup == 0) sigpause(0);
}
-- 

				Sarima (Stanley Friesen)

{trwrb|allegra|cbosgd|hplabs|ihnp4|aero!uscvax!akgua}!sdcrdcf!psivax!friesen
or {ttdica|quad1|bellcore|scgvaxd}!psivax!friesen



More information about the Comp.unix.wizards mailing list