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

  • SEARCH
  • Home
  • 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 7178319
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T16:53:51+00:00 2026-05-28T16:53:51+00:00

I would like to control a separate process with a classic 1), 2), 3),

  • 0

I would like to control a separate process with a classic 1), 2), 3), etc. menu system. Similar to piping an input file in to control the process, I would like to use Ruby to control the process’ $stdin and $stdout. I’ve experimented with IO.popen and Open3.popen3, but cannot seem to get it to work. The documentation examples are not clear (but I’m also quite new to this sort of programming).

The basic idea is:

Open3.popen3("./server") do |stdin,stdout,stderr|
  stdout.gets
  stdin.puts "1"
  stdout.gets
  stdin.puts "2"
  stdout.gets
end

Currently, the first stdout.gets gets the correct header, but then the program seems to hang. Can anybody offer any advice? I’ve been googling for a while now but haven’t found anything.

Thanks!

  • 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-28T16:53:53+00:00Added an answer on May 28, 2026 at 4:53 pm

    IPC (Inter Process Communication) is very complicated. When working with IPC you need to flush the buffer after every write operation. It would look like this:

    Open3.popen3("./server") do |stdin,stdout,stderr|
      stdout.gets
      stdin.puts "1"
      stdin.flush
      stdout.gets
      stdin.puts "2"
      stdin.flush
      stdout.gets
    end
    

    It’s ugly, but you can redefine puts as a singleton method on stdin (you can do the same with print and write, if needed):

    class <<stdin
      old_puts=method(puts)
      def puts(str)
        old_puts[str]
        flush
      end
    end
    

    This will save allot of trouble if you are doing a lot of IPC.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to control options on the debugger without using the debugging GUI's,
I would like to control which methods appear when a user uses tab-completion on
We have a PHP project that we would like to version control. Right now
I would like to host a silverlight control in winforms via a winforms browser,
I would like to be able to control a flash movie stream using JavaScript
I would like to develop a reusable UI control for iPhone. How should I
I would like to bind a TreeView control I have defined in XAML to
I would like to create a custom control in my Android App. It will
I would like to create a simple control that inherits from HeaderedContentControl, and has
I would like to bind C-` (control-backquote) but I could not do it. The

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.