Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site psivax.UUCP Path: utzoo!watmath!clyde!burl!ulysses!mhuxr!mhuxt!houxm!vax135!cornell!uw-beaver!tektronix!hplabs!sdcrdcf!psivax!friesen From: friesen@psivax.UUCP (Stanley Friesen) Newsgroups: net.unix-wizards Subject: sub-second sleeps on BSD 4.2 Message-ID: <408@psivax.UUCP> Date: Mon, 22-Apr-85 12:50:09 EST Article-I.D.: psivax.408 Posted: Mon Apr 22 12:50:09 1985 Date-Received: Thu, 25-Apr-85 07:44:02 EST Reply-To: friesen@psivax.UUCP (Stanley Friesen) Organization: Pacesetter Systems Inc., Sylmar, CA Lines: 35 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 #include 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