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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T20:49:43+00:00 2026-05-15T20:49:43+00:00

I am using the open4 gem and having problems reading from the spawned processes

  • 0

I am using the open4 gem and having problems reading from the spawned processes stdout. I have a ruby program, test1.rb:

print 'hi.' # 3 characters
$stdin.read(1) # block

And another ruby program in the same directory, test2.rb:

require 'open4'

pid, stdin, stdout, stderr = Open4.popen4 'ruby test1.rb'
p stdout.read(2) # 2 characters

When I run the second program:

$ ruby test2.rb

It just sits there forever without printing anything. Why does this happen, and what can I do to stop it?

  • 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. Editorial Team
    Editorial Team
    2026-05-15T20:49:44+00:00Added an answer on May 15, 2026 at 8:49 pm

    I needed to change test1.rb to this. I don’t know why.

    print 'hi.' # 3 characters
    $stdout.flush
    $stdin.read(1) # block
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been using the spreadsheet gem from http://spreadsheet.ch/ to read in seed data
I am having problems in order to debug an app using ruby-debug with RadRails.
I'm using the ruby serial port gem. After I open up the port I
Occasionally when accessing OpenX 2.8.1 via its XMLRPC api (using the ruby 'openx' gem),
Using ruby 1.9 and latest gem install pcap + fix for compiling (convert ->ptr
I'm using the Pony gem to send emails. Assuming that I have both options
I have installed a GEM called Ziya using the terminal in Mac OSx. However,
ruby version is 1.9.2p290 I am using the following gemset D:\work\software\mongoid>gem list * LOCAL
I am developing a small Ruby-on-rails application. I am using 'roo' gem to open
I'm using the Ruby Gem 'Rawler' to document any broken links on a large

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.