Subject: Re: usleep and signals
To: maximum entropy <entropy@zippy.bernstein.com>
From: Rick Byers <rickb@iaw.on.ca>
List: current-users
Date: 08/18/1997 12:21:16
On Mon, 18 Aug 1997, maximum entropy wrote:

> >Your patch for usleep worked fine.  The nanosleep man page even says it
> >will return an error if tv_nsec is greater than 1 billion (1 second).  The
> >usleep man page should be changed to reflect the fact that usleep will
> >cancel upon receipt of a signal (and will set errno).  Personally, I don't
> >like this.  It should either ignore signals, or return the unslept time.
> >We could easily put the nanosleep in a loop and keep sleeping for the
> >unslept time to ensure usleep sleeps as long as it should.  Or is usleep
> >expected to return when a signal is delivered?
> 
> Yes, usleep() is expected to be interrupted by signals.  The fact that
> it doesn't return the unslept time is an annoyance, but probably needs
> to stay that way or compatibility with hundreds of software packages
> could potentially be lost.  You'd be surprised how many packages
> declare "void usleep()" somewhere in the code.

Thats what I was affraid of... Oh well, now that we can use nanosleep it's
not a big deal.

> I sent in a pr with my patch this morning.  The pr mentions that you
> found the bug.
> I agree with you that the man page for usleep could be more explicit
> about how signals are handled.  You may want to file a doc-bug pr.

Thanks!  I'll send a pr for the man page.
	Rick

=========================================================================
Rick Byers                                      Internet Access Worldwide
rickb@iaw.on.ca                                System Admin, Tech Support
Welland, Ontario, Canada                                    (905)714-1400
http://www.iaw.on.ca/rickb/                         http://www.iaw.on.ca/