This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: problem with 'nanosleep()'
- From: Andrew Haley <aph at redhat dot com>
- To: "Divy Kanungo" <divyk at bgnet dot bgsu dot edu>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Thu, 22 Feb 2007 10:43:32 +0000
- Subject: Re: problem with 'nanosleep()'
- References: <1172139403-29118.00018.00017-smmsdV2.1.6@smtp.bgsu.edu>
Divy Kanungo writes:
> I have following piece of code that ran fine with gcc 3.x
>
> req.tv_sec = 5;
> req.tv_nsec = 10000000; //100ms
> do{
> rc = nanosleep(&req, &rem);
> } while(rem.tv_sec != 0 || rem.tv_nsec !=0);
>
> After upgrade to gcc 4.1.1 the above code goes to infinite loop.
> is this a bug in gcc 4.x ? How do I resolve this?
Read the nanosleep man page.
You need something like
if (rc == -1)
req = rem;
Andrew.