I have a JAVA code where I am executing a perl script. Some scripts donot return a response code but require passwords for execution. My code does not return in those cases and process.waitFor() endlessly waits. Is there a way I can handle this?
Process process = pb.start();
int returnCode = process.waitFor();
System.out.print("return code>>"+ returnCode );
My code has the objective to run the command and show the response code.
I see two choices here:
OutputStream
through Proecess::getOutputStream
so that you can correctly send input and let the process finish Process::destroy
or Process::destroyForcibly
) but this implies that you must choose a maximum amount of time to wait before doing so (and could create problems since you are actually trying to kill a process maybe in the middle of some operation)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.