You need to use a channel, and set it to non-blocking.  I haven't been
able to find the code I wrote, but look up
java.nio.channels.Pipe.


Sam Seaver wrote:


I knew it was something like that!

I just had a look at the NIO classes, and to be honest, i dont see where
they fit in, it would be great to simply have non-blocking IO, but does
anyone have an example of how I can have a non-blocking read of output
and
stderr?

Thanks
Sam




I'm not sure but it I would guess at one of two issues:

  1. You don't seem to be reading the output and stderr in the
     fragment.  You need to keep these channels moving, otherwise the
     process will hang trying to deliver output.  You could consider
     setting the IO to /dev/null (or NUL:) in the script so as to
     assure there is no output pending.
  2. If you do start reading from these, keep in mind that the
     container is usually in charge of managing threads.  Since most
     examples show creating threads to read and process the output,
     this may be a problem.  This is because the default read/write
     facilities don't support non-blocking IO, you need to use the NIO
     classes for that.



Sam Seaver wrote:

I have a JSP web interface that runs a perl script natively using a
bean:

String[] cmd ={"/home/seaver/MONSTER/monster", "-i" + getJobID(),
filePath +
dir + getPdbFileName()};
       try{
           Process proc = Runtime.getRuntime().exec(cmd);
           BufferedWriter output = new BufferedWriter(new
OutputStreamWriter(proc.getOutputStream()));
           BufferedReader input = new BufferedReader(new
InputStreamReader(proc.getInputStream()));
           BufferedReader error = new BufferedReader(new
InputStreamReader(proc.getErrorStream()));
       }catch (Throwable t){
           t.printStackTrace();
       }

The program perl script, monster, runs fine natively, and it runs fine
when
activated from the web interface.

The files passed into the web interface contains records which monster
parses and then inputs into a small C program.  This all works fine,
even
with multiple records (leading to the one monster instance running
the C
program multiple times)

however, if a file with multiple records is passed through the web
interface, after doing the first few records, the perl script just
simply
suspends.  From the look of the output, it is almost as if it never
recieves
back a PID from the C program, and so it hangs.

But this only happens when i run it via the web interface, so what is
happening here!?

S

_________________________________________________________________
MSN 8 helps eliminate e-mail viruses. Get 2 months FREE*.
http://join.msn.com/?page=features/virus

___________________________________________________________________________


To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html


___________________________________________________________________________


To unsubscribe, send email to [EMAIL PROTECTED] and include in
the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html



_________________________________________________________________ The new MSN 8: advanced junk mail protection and 2 months FREE* http://join.msn.com/?page=features/junkmail

___________________________________________________________________________

To unsubscribe, send email to [EMAIL PROTECTED] and include in the
body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html


___________________________________________________________________________ To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html



Reply via email to