This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: problem with 'nanosleep()'


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]