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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T02:54:37+00:00 2026-05-18T02:54:37+00:00

I have a set of tasks that I need to run from a Ruby

  • 0

I have a set of tasks that I need to run from a Ruby script, however one particular task always waits for EOF on STDIN before quitting.

Obviously this causes the script to hang while waiting for the child process to end.

I have the process ID of the child process, but not a pipe or any kind of handle to it. How could I open a handle to the STDIN of a process to send EOF to 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-18T02:54:37+00:00Added an answer on May 18, 2026 at 2:54 am

    EDIT: Given that you aren’t starting the script, a solution that occurs to me is to put $stdin under your control while using your gem. I suggest something like:

    old_stdin = $stdin.dup
    # note that old_stdin.fileno is non-0.
    # create a file handle you can use to signal EOF
    new_stdin = File::open('/dev/null', 'r')
    # and make $stdin use it, instead.
    $stdin.reopen(new_stdin)
    new_stdin.close
    # note that $stdin.fileno is still 0, though now it's using /dev/null for input.
    # replace with the call that runs the external program
    system('/bin/cat')
    # "cat" will now exit.  restore the old state.
    $stdin.reopen(old_stdin)
    old_stdin.close
    


    If your ruby script is creating the tasks, it can use IO::popen. For example, cat, when run with no arguments, will wait for EOF on stdin before it exits, but you can run the following:

    f = IO::popen('cat', 'w')
    f.puts('hello')
    # signals EOF to "cat"
    f.close
    

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

Sidebar

Related Questions

I have a set of batch-processing tasks that need to be run in an
First, the set up: I have a script that executes several tasks after a
I have a fairly simple, though expensive, task that I need to run in
I need a set of tasks that need to be executed exactly once for
I have set up a Django application that uses images. I think I have
I'm looking for way to PHP to detect if a script was run from
I have a service responsible for many tasks, one of which is to launch
I have an SQL table Tasks with columns Id and State . I need
I have a task that has a durable subscriber on a JMS topic and
We have set up a system where notifications get sent to a user with

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.