Duplicate :
|
|
Relates :
|
|
Relates :
|
|
Relates :
|
|
Relates :
|
|
Relates :
|
|
Relates :
|
|
Relates :
|
Runtime.Exec() freeze when we specify non-exist directory in arg list. REPRODUCE: 1. Compile the below program ===> import java.io.*; public class Exec { public static void main( String argv[] ) { try { File path = new File("/export/home/java/nosuchdir"); // Specify non-exist dir. Process process = Runtime.getRuntime().exec( argv, null, path ); BufferedReader br = new BufferedReader( new InputStreamReader( process.getInputStream() ) ); String line; while( (line = br.readLine()) != null ) System.out.println( line ); } catch( IndexOutOfBoundsException e ) { System.err.println( "Usage:java ExecTest command [args...]" ); System.exit(-1); } catch( Exception e ){ System.err.println( "Error:" + e.toString() ); System.exit(-1); } } } <=== 2. Launch the "java Exec ls" (This command line try to "ls" command under the specified directory) Here, no response returns. Note: - When the non-exist directory is specified, an exception should be thrown freeze should not occur. - When existing directory is specified, the "ls" command is execute correctly. CONFIGRATION: OS : Solaris 7, 8 JDK: 1.4.1-b21/1.4.2-beta-b13 ===========================================================================
|