I can see how i can get an OutputStream with a Pipe.sinkChannel as a parameter, but I cannot see how I can go from proc.getOutputStream to the NIO OutputStream...(!)(!)
S
"JC Rules"
From: Eric Noriega <[EMAIL PROTECTED]> Reply-To: "A mailing list for discussion about Sun Microsystem's Java Servlet API Technology." <[EMAIL PROTECTED]> To: [EMAIL PROTECTED] Subject: Re: Suspended processes Date: Tue, 4 Mar 2003 14:44:31 -0500 MIME-Version: 1.0 Received: from mc10-f32.bay6.hotmail.com ([65.54.166.168]) by mc10-s5.bay6.hotmail.com with Microsoft SMTPSVC(5.0.2195.5600); Tue, 4 Mar 2003 11:40:39 -0800 Received: from swjscmail2.java.sun.com ([192.18.99.108]) by mc10-f32.bay6.hotmail.com with Microsoft SMTPSVC(5.0.2195.5600); Tue, 4 Mar 2003 11:39:30 -0800 Received: from swjscmail1 (swjscmail1.Sun.COM [192.18.99.107])by swjscmail2.java.sun.com (Postfix) with ESMTPid 936A022326; Tue, 4 Mar 2003 12:35:16 -0700 (MST) Received: from JAVA.SUN.COM by JAVA.SUN.COM (LISTSERV-TCP/IP release 1.8d) with spool id 5960327 for [EMAIL PROTECTED]; Tue, 4 Mar 2003 12:32:41 -0700 Received: from fourier.sag.gwu.edu (fourier.sag.gwu.edu [128.164.127.73]) by swjscmail1.java.sun.com (Postfix) with ESMTP id 16A3A484E for <[EMAIL PROTECTED]>; Tue, 4 Mar 2003 12:32:41 -0700 (MST) Received: from fuchs.sag.gwu.edu (fuchs.sag.gwu.edu [192.168.61.126]) by fourier.sag.gwu.edu (Sun Internet Mail Server sims.4.0.2000.05.17.04.13.p6) with ESMTP id <[EMAIL PROTECTED]> for [EMAIL PROTECTED]; Tue, 4 Mar 2003 14:38:38 -0500 (EST) Received: from fermi.nit.gwu.edu (localhost [127.0.0.1]) by fuchs.sag.gwu.edu (8.10.2+Sun/8.10.2) with ESMTP id h24JYi302515 for <[EMAIL PROTECTED]>; Tue, 04 Mar 2003 14:34:44 -0500 (EST) Received: from gwu.edu ([128.164.229.111]) by fermi.nit.gwu.edu (8.12.8/8.12.8) with ESMTP id h24JcN3C029955 for <[EMAIL PROTECTED]>; Tue, 04 Mar 2003 14:38:24 -0500 (EST) X-Message-Info: dHZMQeBBv44lPE7o4B5bAg== Delivered-To: [EMAIL PROTECTED] X-Accept-Language: en-us, en User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.2) Gecko/20021120 Netscape/7.01 References: <[EMAIL PROTECTED]> Message-ID: <[EMAIL PROTECTED]> Sender: "A mailing list for discussion about Sun Microsystem's Java Servlet API Technology." <[EMAIL PROTECTED]> Organization: The George Washington University, Department of Computer Science Return-Path: [EMAIL PROTECTED] X-OriginalArrivalTime: 04 Mar 2003 19:39:31.0506 (UTC) FILETIME=[C6E29120:01C2E285]
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
_________________________________________________________________ The new MSN 8: smart spam 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
