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 186735
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T15:41:57+00:00 2026-05-11T15:41:57+00:00

What happens when you call WaitForSingleObject() on a handle you’ve created with CreateFile() or

  • 0

What happens when you call WaitForSingleObject() on a handle you’ve created with CreateFile() or _get_osfhandle()?

For reasons not worth explaining I would like to use WaitForSingleObject() to wait on a HANDLE that I’ve created with _get_osfhandle(fd), where fd comes from a regular call to _open(). Is this possible?

I have tried it in practice, and on some machines it works as expected (the HANDLE is always in the signaled state because you can read more data from it), and on some machines WaitForSingleObject() will block indefinitely if you let it.

The MSDN page for WaitForSingleObject() says that the only supported things that it handles are ‘change notifications, console input, events, memory resource notifications, mutex, processes, semaphores, threads, and waitable timers.’

Additionally, would it be different if I used CreateFile() instead of _get_osfhandle() on a CRT file descriptor?

  • 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. 2026-05-11T15:41:58+00:00Added an answer on May 11, 2026 at 3:41 pm

    Don’t do it. As you can see, it has undefined behavior.

    Even when the behavior is defined, it’s defined in such a way as to be relatively not useful unless you don’t like writing additional code. It is signaled when any asynchronous I/O operation on that handle completes, which does not generalize to tracking which I/O operation finished.

    Why are you trying to wait on a file handle? Clearly the intent matters when you are doing something that isn’t even supported well enough to not block indefinitely.

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

Sidebar

Related Questions

What happens when you call notifyAll method on an object that is not waiting?
Wondering what really happens when i call setCancelsTouchesInView. It is not covered in the
The Java documentation is not clear on this point. What happens if you call
What happens if I call startUpdatingLocation while startMonitoringSignificantLocationChanges is running? Does significantLocationChange monitoring get
What happens when I call rchisq(100,1:100,1:100) : does R generate 100 numbers with df=1,ncp=1?
If I call setIndentationLevel: on an NSMenuItem then nothing happens, if I call indentationLevel
i have a snippet call like this: [!mysnippet?&content=`[*content*]` !] What happen is that, if
Yes, I'm being lazy. What happens when I call performSelector:onThread:... and pass in a
What happens when I call a Javascript function which takes parameters, without supplying those
What happens when you call -init multiple times on one object, are there some

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.