[2702] in java-interest

home help back first fref pref prev next nref lref last post

External process execution problem

daemon@ATHENA.MIT.EDU (satoh-HAL-osamu)
Wed Oct 11 04:18:15 1995

From: pfu.fujitsu.co.jp!satoo@fujitsuI.fujitsu.com (satoh-HAL-osamu)
To: java-interest@java.Eng.Sun.COM
Date: Wed, 11 Oct 1995 15:03:13 +0900

Hiya,

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

Thanks in advance,
SATOH Osamu

-
Note to Sun employees: this is an EXTERNAL mailing list!
Info: send 'help' to java-interest-request@java.sun.com

home help back first fref pref prev next nref lref last post