Re: problem with 'nanosleep()'

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux