NO

Author Topic: to sleep() or not to Sleep()  (Read 3929 times)

liquiz

  • Guest
to sleep() or not to Sleep()
« on: March 31, 2006, 12:09:11 AM »
I just recently had need of adding a sleep to a program I was working on.  Since the program compiles under both Linux and Pelles C I try and avoid using any windows specific features.

Under Linux gcc there is a header unistd.h that contains the sleep() command.
Under Windows/Pelles C/MSVC there is a header windows.h that contains Sleep().

I looked at he unistd.h file that Pelles C includes during install and there appears to be a commented out sleep().


Questions:
1.  Why is it commented out.
2.  Any chance of getting it added "back" in.

I just really hate using #if/#endif :)

Peace,
Liquiz

Offline Pelle

  • Administrator
  • Member
  • *****
  • Posts: 2266
    • http://www.smorgasbordet.com
Re: to sleep() or not to Sleep()
« Reply #1 on: April 01, 2006, 08:57:46 AM »
Quote from: "liquiz"
1.  Why is it commented out.

Most of the functions commented out in unistd.h are hard to implement on Windows. If I understand Posix correctly, the sleep() function can be interrupted by a signal. This complicate things...

Quote from: "liquiz"
2.  Any chance of getting it added "back" in.

Maybe. Considering the few signals that can be supported on Windows, in practice we are probably talking about Ctrl+C... It might be possible to support it...

Pelle
/Pelle