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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T00:40:48+00:00 2026-05-16T00:40:48+00:00

I have the following snippet calling a perl script which writes to STDERR and

  • 0

I have the following snippet calling a perl script which writes to STDERR and STDOUT.
I’ve been following the recomended procedures such as auto flushing the STDOUT and STDERR in the perl script and using streamgobbler threads. I’ve noticed this to help my issue in to a degree but at times where the perl script generates large volumes of output it will still fill up its pipes and hang. The only thing that seems to stop this adding the following to my perl script however obviously I would like the output so this is not an option.

update >>

Another interesting occurence is when I cat the /proc/pid/fd/pipe# in linux it causes the pipe to be read to be accessed. This seems to dump the content of the pipe meaning my perl process can again write to it and thus complete. Must be therefore my java process is not reading the process output stream properly.

PERL :

close STDOUT 
close STDERR

My java looks like the following

   parserProcess = run.exec(config.getCMDArray(),env);

StreamGobbler errorGobbler = new StreamGobbler(parserProcess.getErrorStream(), "ERROR");

  // any output?
     StreamGobbler outputGobbler = new StreamGobbler(parserProcess.getInputStream(), "OUTPUT");

  // kick them off
     errorGobbler.start();
     outputGobbler.start();

whereby StreamGobbler is ->

class StreamGobbler extends Thread
{
    InputStream is;
    String type;

StreamGobbler(InputStream is, String type)
{
    this.is = is;
    this.type = type;
}

public void run()
{
    try
    {
        InputStreamReader isr = new InputStreamReader(is);
        BufferedReader br = new BufferedReader(isr);
        String line=null;
        while ( (line = br.readLine()) != null)
            System.out.println(type + ">" + line);    
        } catch (IOException ioe)
          {
            ioe.printStackTrace();  
          }
}
}



 String line="";

 status = parserProcess.waitFor();

Thanks in advance

  • 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-16T00:40:49+00:00Added an answer on May 16, 2026 at 12:40 am

    I think you’re describing normal behavior for your perl and java apps. The actual size of the buffer behind a pipe is undefined/OS dependent but it could be as little as 1KB or 16KB. It is good and sensible for the output-producing process to block until its text has been consumed; what would be the alternative? Allocating ever bigger amounts of memory for the pipe buffer?

    If you’re using the above code to experiment, then your processing speed is bottlenecked by Java’s console output, i.e. the System.out.println() calls. I think if you commented the printing out (just for testing), you’d see Java slurping up the Perl output quite snappily.

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

Sidebar

Related Questions

I have the following snippet in a bash script written in Solaris 10: printf
I have this following snippet in my ANT-buildfile, which reads filenames from a file
I have the following code snippet: <div id=listbox1div style=z-index:95; background:white; overflow-y:auto; overflow-x:hidden; width:240; height:314px;>
I have the following snippet below from my script that's using a WebRequest to
I have the following snippet of code of which I do not have access
I have following code snippet and i am trying to evaluate the time take
I have following code snippet that i use to compile class at the run
I have following code snippet: class ABC{ public: int a; void print(){cout<<hello<<endl;} }; int
I have the following snippet in one of my html pages : <div class=inputboximage>
I have the following snippet of code, changeTextArea is a TextArea object. changeTextArea.addKeyboardListener(new KeyboardListenerAdapter()

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.