Strange Windows warning with IO.popen: The process tried to write to a nonexistent pipe

D

Daniel Berger

Hi all,

Ruby 1.8.6
Windows XP Pro

I tried this standalone snippet:

io = IO.popen('date /t')

Running that with -w I get this warning:

The process tried to write to a nonexistent pipe

However, if I add a simple "io.read" on the next line the warning goes
away. I do not see the same warning on Unix systems.

What's the deal?

Thanks,

Dan
 
L

Luis Lavena

Hi all,

Ruby 1.8.6
Windows XP Pro

I tried this standalone snippet:

io = IO.popen('date /t')

Running that with -w I get this warning:

The process tried to write to a nonexistent pipe

I got the same without the -w option.

This is related to the redirection of stdio and stdout and the
premature termination of them (in the child process spawn by ruby).

If you add a Kernel.gets() or anything that delays the script
termiantion you wouldn't get the warning.

HTH,
 
D

Daniel Berger

Luis said:
I got the same without the -w option.

This is related to the redirection of stdio and stdout and the
premature termination of them (in the child process spawn by ruby).

If you add a Kernel.gets() or anything that delays the script
termiantion you wouldn't get the warning.

So, how do we fix it Luis?

Regards,

Dan
 
L

Luis Lavena

So, how do we fix it Luis?

To be more exact, the error message is not coming from ruby itself,
but is the output genereated by STDERR from the child process being
captured by the console you're running.

This is a small example, doing the same thing with FreeBASIC:

open pipe "date /t" for input as #1

(compile with fbc.exe) and the output will be:

D:\Users\Luis\Desktop>u
The process tried to write to a nonexistent pipe.
The process tried to write to a nonexistent pipe.

The same problem shows when you try to use "echo" and pipes in batch
files from time to time, there is no guarantee that the pipe will
exist at that time, and ruby is closing itself before the child
process can actually execute.

Adding a sleep also prevent from getting the warning, but this seems
to have been raised in every language or scripting processor (VBScript
and PowerShell) too.

What are you trying to do? if you're just ignoring the output of the
'date /t', why don't you use backtick syntax?

io = `date /t`

Using that syntax worked all the time, (from 10 runs, I got 0 error
messages).

Regards,
 
N

Nobuyoshi Nakada

Hi,

At Wed, 20 Feb 2008 07:02:31 +0900,
Daniel Berger wrote in [ruby-talk:291663]:
Ruby 1.8.6
Windows XP Pro

I tried this standalone snippet:

io = IO.popen('date /t')

Running that with -w I get this warning:

The process tried to write to a nonexistent pipe

I have deja vu on this question..., the thread from
[ruby-core:14126] can't help you?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top