[#2367] Standard libraries — Dave Thomas <dave@...>

From ruby-dev summary:

60 messages 2004/02/11

[#2397] PATCH: deprecate cgi-lib, getopts, importenv, parsearg from standard library — Gavin Sinclair <gsinclair@...>

Index: cgi-lib.rb

15 messages 2004/02/12

[#2465] PATCH: OpenStruct#initialize to yield self — Gavin Sinclair <gsinclair@...>

This is a common approach I use to object initialization; I don't know

24 messages 2004/02/19

Re: Nested popens under OSX

From: Chad Fowler <chad@...>
Date: 2004-02-26 11:49:24 UTC
List: ruby-core #2512
On Feb 19, 2004, at 12:39 PM, Dave Thomas wrote:

> The following code fails under OSX:
>
> - - - - - - - - - -
> code = %q{
>   pipe = IO.popen("-","w+")
>   if pipe
>     pipe.puts "Get a job!"
>     $stderr.puts "Child says '#{pipe.gets.chomp}'"
>   else
>     $stderr.puts "Dad says '#{gets.chomp}'"
>     puts "OK"
>   end
> }
>
> require 'rbconfig'
>
> ruby = open("|ruby 2>&1", "w+")
> ruby.puts code
> ruby.close_write
> result = ruby.readlines
> ruby.close
>
> puts result
> - - - - - - - - - -
>
> I get:
>
> dave[Work/rubybook 11:33:33] ruby t.rb
> -:7: private method `chomp' called for nil:NilClass (NoMethodError)
> -:5: private method `chomp' called for nil:NilClass (NoMethodError)
> dave[Work/rubybook 11:34:06] ruby t.rb
> -:7: private method `chomp' called for nil:NilClass (NoMethodError)
> -:4:in `write': Broken pipe (Errno::EPIPE)
>         from -:4:in `puts'
>         from -:4
>
> However it works fine under Linux.
>
> If I run just the code in 'code' it works fine.
>
> Am I doing something stupid (the likely case), or is there a problem 
> running popen inside a process that's run using popen?
>
>

I wasn't able to find the problem, but I can confirm that I see the 
same results on Mac OS with ruby 1.8.1 (2003-12-25) [powerpc-darwin].

To simplify things, I took the "code" part and put it in a separate 
file (brokenpipes) and then did:

tashi-delek:~/download/ruby-1.8.1 chadfowler$ cat brokenpipes |ruby 2>&1
Dad is 992
-:9: private method `chomp' called for nil:NilClass (NoMethodError)
-:3:in `write': Broken pipe (Errno::EPIPE)
         from -:3:in `puts'
         from -:3

I spent a little bit of fruitless time in the debugger and then 
realized  better go avoid being late for work!

Chad


In This Thread

Prev Next