Date: Sun, 18 May 1997 17:10:45 +0800 From: Peter Wemm <peter@spinner.DIALix.COM> To: Bruce Evans <bde@zeta.org.au> Cc: cvs-all@FreeBSD.org, cvs-committers@FreeBSD.org, cvs-lib@FreeBSD.org, peter@FreeBSD.org Subject: Re: cvs commit: src/lib/libc/gen usleep.c Message-ID: <199705180910.RAA06230@spinner.DIALix.COM> In-Reply-To: Your message of "Sun, 18 May 1997 18:38:59 %2B1000." <199705180838.SAA30604@godzilla.zeta.org.au>
next in thread | previous in thread | raw e-mail | index | archive | help
Bruce Evans wrote: > >> Where do those semantics appear? The old behaviour was to return > >> early. The man page said otherwise, but so does the BSD4.4-Lite man > > ^^^^^ > >Are you sure of that? Both sleep() and usleep() do a 'while > >(!ringring) sigpause(...)'.. To my reading, it won't return early ever... .. I meant to specify that it wouldn't return early for signals other than SIGALRM. :-) > I haven't read the sources lately, but the example > > alarm(1); > sleep(2); > > has been been returning early (and not returning the remaining time so it > has been on my bug list) for years. Yes. This should be fixed now.. The version that I posted a short while ago (with all #ifdef's stripped so it was a reasonable size for the mail) should handle this assumed case pretty much correctly. > Erm, ringring is set after the first SIGALRM is caught, so sleep() and > usleep() return after the first alarm. The loop prevents returning after > other signals are caught. Catching alarms prevents external SIGALRMs > from killing the process. I added a 'do nothing' signal handler for SIGALRM for this purpose. It's not unreasonable to expect that there are quite a few programs that have taken advantage of the conventional implementation. > POSIX.1 seems to specify returning early from sleep() whenever a signal > (of any type) is caught. Yes, we violated this quite badly.. :-( Where did the sleep(3) code come from? It looks like it's from Lite-1 and that it's busted there. Was it in the net-2 code as well? > Bruce Cheers, -Peter
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199705180910.RAA06230>