# Regarding \_popen() in windows 2000

**URL:** <https://www.ruby-forum.com/t/regarding-popen-in-windows-2000/114778>\
**Category:** Ruby\
**Created:** [September 17, 2007, 1:25pm UTC](https://www.ruby-forum.com/t/regarding-popen-in-windows-2000/114778 "2007-09-17T13:25:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [September 17, 2007, 1:25pm UTC](https://www.ruby-forum.com/t/regarding-popen-in-windows-2000/114778/1 "2007-09-17T13:25:41Z")

</div>

Hi All,

I have a console application. In windows 2000, \_popen() is returning  
invalid handle. I checked the same app with 2003 Server, its working  
fine.

Please suggest …

Thanks !

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [September 25, 2007, 11:00pm UTC](https://www.ruby-forum.com/t/regarding-popen-in-windows-2000/114778/2 "2007-09-25T23:00:08Z")

</div>

On Sep 14, 12:05 pm, removed\_email\_address@domain.invalid wrote:

> Hi All,
> 
> I have a console application. In windows 2000, \_popen() is returning  
> invalid handle. I checked the same app with 2003 Server, its working  
> fine.

Are you talking about IO.popen? I didn’t think Ruby used \_popen()  
behind the scenes, but it’s been a while since I looked. The \_popen()  
function is basically broken on Windows. From MSDN:

“If used in a Windows program, the \_popen function returns an invalid  
file pointer that will cause the program to hang indefinitely. \_popen  
works properly in a Console application. To create a Windows  
application that redirects input and output, see “Creating a Child  
Process with Redirected Input and Output” in the Platform SDK.”

Regards,

Dan

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [September 25, 2007, 11:04pm UTC](https://www.ruby-forum.com/t/regarding-popen-in-windows-2000/114778/3 "2007-09-25T23:04:03Z")

</div>

On Sep 15, 12:38 am, Daniel B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> function is basically broken on Windows. From MSDN:
> 
> “If used in a Windows program, the \_popen function returns an invalid  
> file pointer that will cause the program to hang indefinitely. \_popen  
> works properly in a Console application. To create a Windows  
> application that redirects input and output, see “Creating a Child  
> Process with Redirected Input and Output” in the Platform SDK.”
> 
> Regards,
> 
> Dan

Thanks a lot! The problem is resolved by setting /MD flag.
