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 if I use SHGetFolderPath api call in a 32 bit system with
The Java documentation is not clear on this point. What happens if you call
Normally, the method of passing workflow parameters to the workflow happens in the call
I would like to be able to change the default behaviour of an ASP.NET
What happens when I call setTimeout in a firefox extension? Is there ever a
I wanted to call a signle function on any event happens for <textarea> .
We call a .live() method like this: $('.link').live('click', loadContent); But what about if I'm
I am somewhat confused by what happens when you call strtok on a char
I guess the question in the title is clear enough.What happens when i call
Does Entity Framework use a transaction for when you call SaveChanges on your context?

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.