1 2 Previous Next 16 Replies Latest reply: Apr 20, 2009 12:17 AM by 794029 RSS

    BufferedReader problems

    794029
      I am running a program using exec().. and trying to get the output to a GUI


      I am trying to get the output from Program_X:

      To start, i have:
      (im not showing the error stream)
                  Runtime r = Runtime.getRuntime();
                  Process proc = r.exec("PROGRAM_X");
                  InputStream in = proc.getInputStream();
                  InputStreamReader inStreamReader = new InputStreamReader(is);
                  BufferedReader inBr = new BufferedReader(inStreamReader);
             // Im also doing this for the error stream
      Then to get the output i originally had:
      String inLine = "";
      while(inLine != null)
      {
        line = inBr.readLine();
        // code to append string to GUI
      }
      This works in most cases, but:
      Problem 1: sometimes the output is not a full line (depends on the input to Program_X). Then the GUI never gets the line. To fix this i instead had the GUI read one byte at a time.
      byte inLine = "";
      while(inLine != null){
        if(inBr.ready())
         {
           line = inBr.read() ; // Later i make the byte a string
           // code to append string to GUI
          }
      }
      Now, if I Program_X does not have a full line, it can still get all the text. (so my 1 problem was fixed).

      But now.. if i run Program_X with the other input.. it never gets past the "inBr.ready()". (i watched it get stuck there with a debugger)

      So now i have a new problem that dosent make sense to me.

      How can something be able to read a line, but if i change it to just read a byte, it dosent work?
      inBr.readLine();// Why can this work on a program
                      //
                      // But...
      if (inBr.ready())// this is always false?
      {
        inBr.read();
      }
      I dont understand how the BufferedReader can be NOT "Ready" but also ablt to do "readLine"?

      Edited by: 00jt on Apr 11, 2009 4:48 PM
        • 1. Re: BufferedReader problems
          793415
          >
          (im not showing the error stream)>
          It does not matter if you throw the error stream into a bottomless pit, but it must be read, or Process can block.
          • 2. Re: BufferedReader problems
            794029
            AndrewThompson64 wrote:
            >
            (im not showing the error stream)>
            It does not matter if you throw the error stream into a bottomless pit, but it must be read, or Process can block.
            Sorry, let me rephrase that..

            I am computing the error stream, and running it... but i am not showing my code here.

            I said that in my code:
            Runtime r = Runtime.getRuntime();
                        Process proc = r.exec("PROGRAM_X");
                        InputStream in = proc.getInputStream();
                        InputStreamReader inStreamReader = new InputStreamReader(is);
                        BufferedReader inBr = new BufferedReader(inStreamReader);
                   // Im also doing this for the error stream <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
            So yea, i have another window that shows the error stream, i just am not showing it in my Question.

            Edited by: 00jt on Apr 11, 2009 5:06 PM
            • 3. Re: BufferedReader problems
              793415
              >
              I am computing the error stream, and running it... but i am not showing my code here.

              I said that in my code:
              ....
              // Im also doing this for the error stream <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
              I missed that, since I was skipping the comments. My bad.

              It does lead me though, to a piece of advice I almost included on the original thread.

              You get a greater chance of help, faster, if you can prepare an SSCCE that demonstrates the behavior. This is harder for code that calls an external program, since few people who read the code will have program X, but it is generally more informative than code snippets (with or without comments).
              • 4. Re: BufferedReader problems
                794029
                AndrewThompson64 wrote:

                I missed that, since I was skipping the comments. My bad.

                It does lead me though, to a piece of advice I almost included on the original thread.

                You get a greater chance of help, faster, if you can prepare an SSCCE that demonstrates the behavior. This is harder for code that calls an external program, since few people who read the code will have program X, but it is generally more informative than code snippets (with or without comments).
                I Don't think my boss would want program X to be online (its not my code)

                So...
                do you know what possible output would cause a BufferedReader to be able to do a "br.readLine()" but at the same time it would not have a "br.ready()"?
                • 5. Re: BufferedReader problems
                  EJP
                  readLine() reads lines. It doesn't return until a line terminator has been read. No newline -> no line. If only the first half of the line is available, ready() is true and readLine() continues to block.

                  If you want half lines or individual characters, don't use readLine() at all. Just call read(). And don't use ready(), it's pointless, just block in the read.
                  • 6. Re: BufferedReader problems
                    800345
                    Reading the process' Output Stream and Error Stream need to be read concurrently, since they can be filling up at the same time. So you should have a Thread that does the Stream Reading.

                    JavaWorld has a good article about Runtime.exec() called "When Runtime.exec() won't!". It is a must read, and provides code for a good 'StreamGobbler' which consumes both of the process' buffers. Here is a link: [When Runtime.exec() Won't|http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html] but it seems to be down at the moment.

                    Below is a quick example of code that does what you are asking. The StreamGobbler is loosely based the one provided in the above article. It uses the Java 6 interface java.lang.Appendable interface for Output (if you are working with an older version of Java you will have to implement your own).
                    /* The StreamGobbler - Consumes InputStreams */
                    package net.thelukes.util;
                    
                    import java.io.BufferedReader;
                    import java.io.IOException;
                    import java.io.InputStream;
                    import java.io.InputStreamReader;
                    
                    public class StreamGobbler implements Runnable
                    {
                        private final String prefix;
                        private final Appendable out;
                        private final BufferedReader in;
                        private Thread gobblerThread;
                        
                        public StreamGobbler(InputStream input, String prefix, Appendable output)
                        {
                            this.prefix = (prefix == null) ? "" : (prefix + ": ");
                            this.out = output;
                            this.in = new BufferedReader(new InputStreamReader(input));
                        }
                        
                        public void start()
                        {
                            gobblerThread = new Thread(this, "StreamGobbler: "+prefix);
                            gobblerThread.start();
                        }
                        
                        public void run()
                        {
                            String line = "";
                            while(!Thread.interrupted() && line != null)
                            {
                                try
                                {
                                    line = in.readLine();
                                    if (line != null)
                                        out.append(prefix + line + "\n");
                                } catch (IOException e)
                                { /* likely to occur if the input is closed, but
                                   * that is okay, just stop reading from it and die. 
                                   */
                                    Thread.currentThread().interrupt();
                                    
                                    e.printStackTrace();
                                }
                            }
                        }
                    }
                    /* An Appendable implementation for JTextComponents */
                    package net.thelukes.util;
                    
                    import java.io.IOException;
                    
                    import javax.swing.SwingUtilities;
                    import javax.swing.text.JTextComponent;
                    
                    public class JTextComponentAppendable implements java.lang.Appendable
                    {
                        private final JTextComponent output;
                        
                        public JTextComponentAppendable(JTextComponent toAppendTo)
                        {
                            this.output = toAppendTo;
                        }
                        
                        @Override
                        public java.lang.Appendable append(final CharSequence input) throws IOException
                        {
                            SwingUtilities.invokeLater(new Runnable() {
                               public void run()
                               {
                                   if (input == null)
                                       output.setText(output.getText() + " null");
                                   else
                                       output.setText(output.getText() + input);
                               }
                            });
                            return this;
                        }
                    
                        @Override
                        public java.lang.Appendable append(final char input) throws IOException
                        {
                            SwingUtilities.invokeLater(new Runnable() {
                                public void run()
                                {
                                    output.setText(output.getText() + input);
                                }
                             });
                            return this;
                        }
                    
                        @Override
                        public java.lang.Appendable append(final CharSequence input, final int start, final int end)
                                        throws IOException
                        {
                            SwingUtilities.invokeLater(new Runnable() {
                                public void run()
                                {
                                    if (input == null)
                                        output.setText(output.getText() + " null");
                                    else
                                        output.setText(output.getText() + input.subSequence(start, end));
                                }
                             });
                            return this;
                        }
                    
                    }
                    /* A test class which will run itself.  With zero arguments it will generate the 
                       GUI, and execute itself with some text.
                       Provide one argument and it sends some text, but not a new line, to the output 
                       Provide two arguments and it sends one complete line of text 
                       Provide three arguments and it sends 10 lines of text to the output.
                       It doesn't matter what the application arguments are.
                    */
                    package external.app;
                    
                    import java.awt.Dimension;
                    import java.io.IOException;
                    
                    import javax.swing.JFrame;
                    import javax.swing.JPanel;
                    import javax.swing.JScrollPane;
                    import javax.swing.JSplitPane;
                    import javax.swing.JTextArea;
                    
                    import net.thelukes.util.JTextComponentAppendable;
                    import net.thelukes.util.StreamGobbler;
                    
                    public class Runner
                    {
                        static void runWithSeveralLines()
                        {
                            for (int i = 0; i < 10; i++)
                            {
                                System.out.println("Line #" + i);
                            }
                        }
                    
                        static void runWithOneLine()
                        {
                            System.out.println("Hello World");
                        }
                    
                        static void runWithNoLines()
                        {
                            System.out.print("A-Ha!");
                        }
                    
                        static void doExternalRunner()
                        {
                            JFrame jf = new JFrame("Output");
                            JTextArea out_ta = new JTextArea();
                                out_ta.setLineWrap(true);
                                out_ta.setWrapStyleWord(true);
                            JScrollPane out_sp = new JScrollPane(out_ta);
                                out_sp.setPreferredSize(new Dimension(250, 250));
                            JTextArea err_ta = new JTextArea();
                                err_ta.setLineWrap(true);
                                err_ta.setWrapStyleWord(true);
                            JScrollPane err_sp = new JScrollPane(err_ta);
                                err_sp.setPreferredSize(new Dimension(250,250));
                            JSplitPane jsp = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,
                                            out_sp, err_sp);
                                jsp.setOneTouchExpandable(true);
                            JPanel jp = new JPanel();
                                jp.add(jsp);
                            jf.setContentPane(jp);
                            jf.pack();
                            jf.setVisible(true);
                            jf.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
                            
                            String[] command = new String[] { "cmd", "/c", "java", "-cp", 
                                            "./bin/", "external.app.Runner", "1", "2", "3"}; 
                            try
                            {
                                Process p = Runtime.getRuntime().exec(command);
                                StreamGobbler out = new StreamGobbler(p.getInputStream(), 
                                                "Output", new JTextComponentAppendable(out_ta));
                                StreamGobbler err = new StreamGobbler(p.getErrorStream(), 
                                                "Error", new JTextComponentAppendable(err_ta));
                                
                                out.start();
                                err.start();
                                
                                p.waitFor();
                            } catch (IOException e)
                            {
                                e.printStackTrace();
                            } catch (InterruptedException e)
                            {
                                e.printStackTrace();
                            }
                        }
                    
                        /**
                         * @param args
                         */
                        public static void main(String[] args)
                        {
                            switch (args.length)
                            {
                                case 1:
                                    runWithNoLines();
                                    break;
                                case 2:
                                    runWithOneLine();
                                    break;
                                case 3:
                                    runWithSeveralLines();
                                    break;
                                default:
                                    doExternalRunner();
                                    break;
                            }
                        }
                    
                    }
                    Edited by: stevejluke on Apr 11, 2009 9:57 PM - Formatting
                    • 7. Re: BufferedReader problems
                      794029
                      ejp wrote:
                      readLine() reads lines. It doesn't return until a line terminator has been read. No newline -> no line. If only the first half of the line is available, ready() is true and readLine() continues to block.
                      I know. my question was why ready() would fail, and readLine() would not. Not the other way around.

                      If you want half lines or individual characters, don't use readLine() at all. Just call read(). And don't use ready(), it's pointless, just block in the read.
                      if i dont use ready(), how do i get it to read from the err stream? This is what i am doing now.
                      while(line != null && err != null)
                      {
                           if(inBr.ready())
                           {
                               line = inBr.read();
                            }
                           if(errBr.ready()
                           {
                             line = errBr.read();
                           }
                      }
                      if I remove the "ready" isnt it possible that "line = inBr.read();" would hang forever if the first part of the output is from the errStream?
                      • 8. Re: BufferedReader problems
                        794029
                        stevejluke wrote:
                        Reading the process' Output Stream and Error Stream need to be read concurrently, since they can be filling up at the same time. So you should have a Thread that does the Stream Reading.

                        JavaWorld has a good article about Runtime.exec() called "When Runtime.exec() won't!". It is a must read, and provides code for a good 'StreamGobbler' which consumes both of the process' buffers. Here is a link: [When Runtime.exec() Won't|http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html] but it seems to be down at the moment.
                        yea, i have read that article before.

                        Below is a quick example of code that does what you are asking. The StreamGobbler is loosely based the one provided in the above article. It uses the Java 6 interface java.lang.Appendable interface for Output (if you are working with an older version of Java you will have to implement your own).
                        Ill look into this code more later, i used something like this before. It seemed that a long time ago. (ive made alot of changes, and had to get some SwingWorkers and such to get stuff working correctly)

                        But if memory serves, it seems like at this part:
                                    
                        out.start();
                        err.start();
                        the program hanged at "out.start()" and never got to err.start().. but Actually, i think i had it implemented differently.. because i dont think i used a runnable object.

                        Thanks for the help

                        Edited by: 00jt on Apr 11, 2009 11:10 PM

                        Edited by: 00jt on Apr 11, 2009 11:10 PM
                        • 9. Re: BufferedReader problems
                          800308
                          stevejluke wrote:
                          Reading the process' Output Stream and Error Stream need to be read concurrently
                          Thank you for the StreamGobbler steve. I'm lifting it... along with your appendable component. Here's my (now daggy) version, for the edification of the masses... Here's how NOT to do it (in >= 1.6).
                          package krc.utilz.process;
                          
                          import java.io.InputStream;
                          import java.io.InputStreamReader;
                          import java.io.BufferedReader;
                          import java.io.OutputStream;
                          import java.io.PrintWriter;
                          
                          public class Piper implements Runnable
                          {
                            public final String name;
                            private final InputStream input;
                            private final PrintWriter writer;
                          
                            public Piper(String name, InputStream input, PrintWriter writer) {
                              this.name = name;
                              this.input = input;
                              this.writer = writer;
                            }
                          
                            public Piper(String name, InputStream input, OutputStream output) {
                              this(name, input, new PrintWriter(output));
                            }
                          
                            @Override
                            public void run() {
                              try {
                                BufferedReader reader = null;
                                try {
                                  reader = new BufferedReader(new InputStreamReader(input));
                                  String line = null;
                                  while ( (line=reader.readLine()) != null ) {
                                    if (name!=null) writer.print(name+": ");
                                    writer.println(line);
                                    writer.flush();
                                  }
                                } finally {
                                  if(reader!=null) reader.close();
                                }
                              } catch (Exception e) {
                                if (name!=null) System.err.print(name+": ");
                                System.err.println(e);
                              }
                            }
                          
                          }
                          I didn't even handle interrupts... Oh the shame ;-)

                          Cheers. Keith.
                          • 10. Re: BufferedReader problems
                            794029
                            Sorry for the long delay.. been busy with alot of stuff.

                            Ive tried your code.. But it it just hangs/dies without compleating "Program X".

                            It hangs on your StreamGobbler:
                                public void run()
                                {
                                    String line = "";
                                    while(!Thread.interrupted() && line != null)
                                    {
                                        try
                                        {
                                            line = in.readLine(); // HANGS Here  <=====================================
                                            if (line != null)
                                                out.append(prefix + line + "\n");
                                        } catch (IOException e)
                                        { /* likely to occur if the input is closed, but
                                           * that is okay, just stop reading from it and die.
                                           */
                                           // Thread.currentThread().interrupt();
                            
                                            e.printStackTrace();
                                        }
                                    }
                                }
                            I am calling it from inside my SwingWorker like this:
                            //....
                                              outputText2 = new
                                                  StreamGobbler(proc2.getInputStream(),"",  new JTextComponentAppendable(myFrame.getOutputArea()));
                                              errorText2 = new
                                                  StreamGobbler(proc2.getErrorStream(),"",  new JTextComponentAppendable(myFrame.getErrorArea()));
                                              outputText2.run(); // This is where it Hangs <===============================================
                                              errorText2.run();
                            //...
                            I think what is happening is that the next stream to have output is the ErrorStream.. but Its never getting to the ErrorStream because just hangs on the outputStream.

                            Program X Alternates from Error and Output.

                            It ALWAYS puts GarbageCollection info into the Error stream.
                            And the rest (except for real errors) go into the outputStream.

                            So it would maybe look like this:
                             Output: Running
                             Output: Tests
                             Output: Begin Computation:
                             Error:    GC#  1.01.004.01
                             Error:    GC#  1.01.004.02
                             Output: More Tests
                             Output: Print Final Results
                            {Code}
                            
                            So, I cant just read in the Input first, i need to read in both parts at once. Should I Perhaps have them run on different threads then? 
                            
                            The way i am doing it now that works (except when there is only errors)
                            public void run() {
                            try
                            {
                            InputStreamReader inStreamReader = new InputStreamReader(is);
                            BufferedReader inBr = new BufferedReader(inStreamReader);

                            InputStreamReader errStreamReader = new InputStreamReader(err);
                            BufferedReader errBr = new BufferedReader(errStreamReader);

                            String inLine= inBr.readLine(); // If i dont do a readLine() it then hangs below.
                            // The only problem is.. if there is only Errors.. then it hangs here
                            String errLine = (errBr.ready())? errBr.read()+"":"";

                            myArea.append(inLine);
                            myErrArea.append(errLine);
                            String DebugString = "";
                            boolean doOutputAutoScroll = true;
                            boolean doErrorAutoScroll = true;
                            boolean EOF=false;

                            do{ // outter loop
                            while(inBr.ready()) // ============ It never passes this if i dont do a ReadLine() first (see above)
                            {                  
                            inLine = (char)inBr.read() + "";
                            myArea.append(inLine);
                            }
                            while(errBr.ready())
                            {                     
                            errLine = ((char)errBr.read())+"";
                            myErrArea.append(errLine);
                            }



                            }
                            System.out.println(DebugString);

                            } catch (IOException ioe)
                            {
                            ioe.printStackTrace();
                            }
                            }while ( inLine != null && errLine != null); // end Outter Loop
                            }
                            Im showing here how i originally had it call inBr.readLine() because there is usually output first (instead of errors).
                            
                            If i dont call inBr.readLine() at the beginning, then for some reason..  "inBr.ready()" never has success.
                            
                            But, if i do call inBr.readLine() at the beginning, it will hang if the first thing is errors....
                            
                            What is going on!                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
                            • 11. Re: BufferedReader problems
                              800308
                              00jt wrote:
                              What is going on!
                              http://java.sun.com/docs/books/tutorial/uiswing/concurrency/worker.html
                              • 12. Re: BufferedReader problems
                                800345
                                00jt wrote:
                                Ive tried your code.. But it it just hangs/dies without compleating "Program X".
                                ...
                                I am calling it from inside my SwingWorker like this:
                                //....
                                outputText2 = new
                                StreamGobbler(proc2.getInputStream(),"",  new JTextComponentAppendable(myFrame.getOutputArea()));
                                errorText2 = new
                                StreamGobbler(proc2.getErrorStream(),"",  new JTextComponentAppendable(myFrame.getErrorArea()));
                                outputText2.run(); // This is where it Hangs <===============================================
                                errorText2.run();
                                //...
                                I think what is happening is that the next stream to have output is the ErrorStream.. but Its never getting to the ErrorStream because just hangs on the outputStream.
                                ...
                                What is going on!
                                You should use the StreamGobblem#start() method to start the StreamGobblers, not the run() method (as I had done in my example code). The run() method just runs the loop, and will do it sequentially. The start() method begins a new Thread, with the effect that the run() method will run concurrently to other code. Both gobblers will be gobbling at the same time (and the main thread can continue in its job as well).

                                [I may go back and change my StreamGobblers to use an private inner class to implement the Runnable, maybe it would help prevent this type of confusion... the public void run() is really just side effect anyway, and should not be called directly...]
                                • 13. Re: BufferedReader problems
                                  794029
                                  I Read it.. but i guess i should read that again...
                                  • 14. Re: BufferedReader problems
                                    794029
                                    Thanks, i just get start() and run() mixed.. lol

                                    1 last question for you:

                                    Program X has this one other weird thing (that other people are trying to fix) but it is causing 1 snag with my GUI.
                                    (Its written in SML and I got some questions on the SML threads to try to fix this but i think it should be possible to get around it with my GUI (for now).)

                                    Anyhow...
                                    Program X is called 3 times in my GUI, it makes/transforms a file 3 different times in succession. but, the 2ed step has a weird error so that the process hangs. But.. i do know what the error it prints out is.. so i would like to use that to kill the process if possible?

                                    Here is the code for running all 3 parts, notice the comments.
                                    Runtime r = Runtime.getRuntime();
                                    Process proc1, proc2, proc3;
                                    StreamGobbler outputText1, outputText2, outputText3;
                                    StreamGobbler errorText1, errorText2, errorText3;
                                    //...... 
                                     
                                                    proc1 =  r.exec(cmdParserArray, myEnv);     
                                                    outputText1 = new
                                                        StreamGobbler(proc1.getInputStream(),null, new JTextComponentAppendable(myFrame.getOutputArea()));
                                                     errorText1 = new
                                                        StreamGobbler(proc1.getErrorStream(),null,  new JTextComponentAppendable(myFrame.getErrorArea()));
                                                    outputText1.start();
                                                    errorText1.start();
                                                    proc1.waitFor();  // I need to wait, because step 2 depends on step 1
                                                    proc1.destroy();  // <-  Im not sure that this is really needed.
                                    // ......
                                    
                                                    proc2 =  r.exec(cmdTransformArray, myEnv);     
                                                    outputText2 = new
                                                        StreamGobbler(proc1.getInputStream(),null, new JTextComponentAppendable(myFrame.getOutputArea()));
                                                     errorText2 = new
                                                        StreamGobbler(proc1.getErrorStream(),null,  new JTextComponentAppendable(myFrame.getErrorArea()));
                                                    outputText2.start();
                                                    errorText2.start();
                                                    proc2.waitFor();    //  ### TODO ### again, i need to wait... but it never finishes because of the Error with Program X
                                                                               
                                                    proc2.destroy(); 
                                    // .....
                                                    proc3 =  r.exec(cmdPPArray, myEnv);     
                                                    outputText3 = new
                                                        StreamGobbler(proc1.getInputStream(),null, new JTextComponentAppendable(myFrame.getOutputArea()));
                                                     errorText3 = new
                                                        StreamGobbler(proc1.getErrorStream(),null,  new JTextComponentAppendable(myFrame.getErrorArea()));
                                                    outputText3.start();
                                                    errorText3.start();
                                                    proc3.waitFor();
                                                    proc3.destroy();
                                    Now I know what the last part of the output from proc2 should be before Program X will hang forever. it is:
                                    "!* unable to process"
                                    So i changed 1 thing to the StreamGobbler
                                     public void run()
                                        {
                                            String line = "";
                                            while(!Thread.interrupted() && line != null)
                                            {
                                                try
                                                {
                                                    line = in.readLine();
                                                    if (line != null)
                                                        out.append(prefix + line + "\n");
                                     // ## Added to Gobbler
                                                    if(line.contains("!* unable to process")) // ### this is last line of output.. try to kill Process ###
                                                    {
                                                       throw new IOException();// this will interupt thread, but i really want to kill the parent process.
                                                    }
                                    // ## End of my add to Gobbler
                                                } catch (IOException e)
                                                { /* likely to occur if the input is closed, but
                                                   * that is okay, just stop reading from it and die.
                                                   */
                                                    Thread.currentThread().interrupt();
                                                    
                                                    e.printStackTrace();
                                                }
                                            }
                                        }
                                    }
                                    Should i not kill the GobblerThread?
                                    Any ideas on how to kill the parent process?
                                    I may need to do some studdying up on process monitors? any recomendations?

                                    My current "hack" around this problem is to just close the input stream. This causes SML to have a "fatal Error". But it does get it to work... lol

                                    Edited by: 00jt on Apr 19, 2009 1:38 PM
                                    1 2 Previous Next