The Artima Developer Community
Sponsored Link

Java Answers Forum
getRuntime().exec(cmdline) hangs subprocess

3 replies on 1 page. Most recent reply: Aug 1, 2002 1:07 PM by Sriram Anandraj

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 3 replies on 1 page
Craig Colarossi

Posts: 2
Nickname: c2
Registered: Jun, 2002

getRuntime().exec(cmdline) hangs subprocess Posted: Jun 27, 2002 1:06 PM
Reply to this message Reply
Advertisement
Running a batch process from java with the following line:
Process p = Runtime.getRuntime().exec("process.bat");
BufferedReader input =
new BufferedReader
(new InputStreamReader(p.getInputStream()));
while ((line = input.readLine()) != null) {
System.out.println(line);
}
input.close();
}

The batch process hangs (only when I call it from Java). The process takes quite a lot of time when run directly from the command prompt (ie. outside Java). The Java doc gives the following info about the Process object:
"some native platforms only provide limited buffer size for standard input and output streams, failure to promptly write the input stream or read the output stream of the subprocess may cause the subprocess to block, and even deadlock". -> don't know how to use this info??

Any help would be apreciated.
Craig


Matt Gerrans

Posts: 1153
Nickname: matt
Registered: Feb, 2002

Re: getRuntime().exec(cmdline) hangs subprocess Posted: Jun 27, 2002 2:04 PM
Reply to this message Reply
If it isn't too much to ask, maybe you can read a few posts down the list. If you are really feeling ambitious you might even search the forum for the plethora of posts pertaining to this subject.

Craig Colarossi

Posts: 2
Nickname: c2
Registered: Jun, 2002

Re: getRuntime().exec(cmdline) hangs subprocess Posted: Jun 27, 2002 2:25 PM
Reply to this message Reply
That was very useful Matt.

Sriram Anandraj

Posts: 1
Nickname: sriram
Registered: Aug, 2002

Re: getRuntime().exec(cmdline) hangs subprocess Posted: Aug 1, 2002 1:07 PM
Reply to this message Reply
I am too facing the same problem "getRuntime().exec(cmdline) hangs subprocess" and also it seems the buffer size is limited to accept data from the subprocess when running from a java program. If you have any idea on this, just let me know how to solve this problem.

Help would be appreciated,
Sriram

Flat View: This topic has 3 replies on 1 page
Topic: Swing v/s HTML Previous Topic   Next Topic Topic: java programming using TerminalIO  and BreezySwing interface

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use