Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8502987
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T01:38:09+00:00 2026-06-11T01:38:09+00:00

I saw in usleep man that : EINVAL usec is not smaller than 1000000.

  • 0

I saw in usleep man that :

EINVAL
usec is not smaller than 1000000. (On systems where that is considered an error.) 

So i wonder if its ok to use usleep in Ubuntu with value greater than 1000000 and if not (or in case that i want to support other platforms ) what is the alternative when i need sleep for 2.2 sec (for example) .

Thank you.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T01:38:10+00:00Added an answer on June 11, 2026 at 1:38 am

    One alternative is to trust the documentation and implement it using a loop just to be safe:

    #define USLEEP_MAX (1000000 - 1)
    
    void long_sleep(unsigned long micros)
    {
      while(micros > 0)
      {
        const unsigned long chunk = micros > USLEEP_MAX ? USLEEP_MAX : micros;
        usleep(chunk);
        micros -= chunk;
      }
    }
    

    You should also inspect the return value of usleep(), I omitted that for brevity.

    In production, you can have fun with Autoconf and friends to detect the proper USLEEP_MAX at compile-time, and even switch to a plain wrapper if the local system doesn’t have a limit for the argument. Hours of fun can be had.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I saw some websites that (for example): if you want to view your message
I saw that even by writing separate commands, we can combine two different types
I saw some html that displays the results of a PHP code just by
I saw a similar question being posted here, yet it did not help me
I saw that programmatically turning bluetooth on and off was a private api thing
I saw on couple of websites that they manage to log you out automatically
I saw this interview question recently for a firm that said: Group of people,
I saw an example that try to explain inheritance in Java. The class Employee,
I saw in school a system that set permissions using binary string. Let's say
Saw some JS notation today that I've never seen before, bear with me if

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.