[2715] in java-interest
Re: External process execution problem
daemon@ATHENA.MIT.EDU (Thomas Ball)
Wed Oct 11 16:10:08 1995
Date: Wed, 11 Oct 1995 10:42:03 -0700
From: Thomas.Ball@Eng.Sun.COM (Thomas Ball)
To: pfu.fujitsu.co.jp!satoo@fujitsuI.fujitsu.com
Cc: java-interest@java.Eng.Sun.COM
This is definitely a bug -- from a cursory look at the source it
appears that you've uncovered a "to be continued" portion of the
UNIXProcess class. I'll investigate this further.
Thank you for taking the time to report this so clearly.
Tom Ball
Java Products Group
> I'm trying to get output of external process through the
> InputStream that the method getInputStream() of class
> java.lang.Process returns.
>
> Occasionaly the java interpreter reports that it received
> sigchild for the process, and hungs up. But it happens
> truly by accsident. No exception seems to be thrown,
> so I cannot handle it.
>
> So my questions are:
>
> Why it happens occasionaly?
> Why the interpreter catches sigchilds?
> How can I ignore sigchilds in java, not in C?
>
> Here is the sample program I wrote:
> --- beggining of source code
> import java.io.*;
> import java.util.*;
>
> class com {
> static void exec(String args[]) {
> Process process = Runtime.getRuntime().exec(args);
> DataInputStream dis = new DataInputStream(process.getInputStream());
> String buf;
> while ((buf = dis.readLine()) != null) {
> System.out.println(">>> " + buf);
> }
> dis.close();
> }
>
> public static void main(String args[]) {
> for (int i = 0; i < 3; i ++) {
> System.out.println("stage " + i);
> exec(args);
> }
> }
> }
> --- end of source code
>
> And I tested this program like below:
>
> --- begginig of messages
> % java com /bin/file ./com.java
> stage 0
> >>> ./com.java: c program text
> stage 1
> pid 10874 status 0
> Received sigchild for 10874 exit=0
> >>> ./com.java: c program text
> stage 2
> >>> ./com.java: c program text
> ^C
> % java com /bin/file ./com.java
> stage 0
> >>> ./com.java: c program text
> stage 1
> >>> ./com.java: c program text
> stage 2
> >>> ./com.java: c program text
> % java com /bin/file ./com.java
> stage 0
> >>> ./com.java: c program text
> stage 1
> pid 10894 status 0
> Received sigchild for 10894 exit=0
> >>> ./com.java: c program text
> stage 2
> >>> ./com.java: c program text
> ^C
> % java com /bin/file ./com.java
> stage 0
> >>> ./com.java: c program text
> pid 10904 status 0
> Received sigchild for 10904 exit=0
> ^C
> % java com /bin/file ./com.java
> stage 0
> >>> ./com.java: c program text
> stage 1
> pid 10912 status 0
> Received sigchild for 10912 exit=0
> >>> ./com.java: c program text
> stage 2
> >>> ./com.java: c program text
> %
> --- end of messages
-
Note to Sun employees: this is an EXTERNAL mailing list!
Info: send 'help' to java-interest-request@java.sun.com