jkavx
asked on
xxcopy hangs
I'm using xxcopy with the code below to do a recursive copy of a given directory. The problem I have is that if I generate an error by leaving a file to be copied open, the process never returns, p.waitFor() just hangs. I'm using the /YY switch which should mean that all prompts are suppressed, so I don't understand why it hangs up when there's an error..
String sSource = getBasePath();
String[] sArrArgs = new String[14];
sArrArgs[0] = "cmd";
sArrArgs[1] = "/c";
sArrArgs[2] = "xxcopy";
sArrArgs[3] = "/CLONE";
sArrArgs[4] = "/PZ0";
sArrArgs[5] = sSource;
sArrArgs[6] = getDestBasePath();
sArrArgs[7] = "/I";
sArrArgs[8] = "/YY";
sArrArgs[9] = "/PB";
sArrArgs[10] = "/H";
sArrArgs[11] = "/Q3";
sArrArgs[12] = "/k0";
sArrArgs[13] = "/VL";
Process p = Runtime.getRuntime().exec( sArrArgs);
p.waitFor();
iRtn = p.exitValue();
String sSource = getBasePath();
String[] sArrArgs = new String[14];
sArrArgs[0] = "cmd";
sArrArgs[1] = "/c";
sArrArgs[2] = "xxcopy";
sArrArgs[3] = "/CLONE";
sArrArgs[4] = "/PZ0";
sArrArgs[5] = sSource;
sArrArgs[6] = getDestBasePath();
sArrArgs[7] = "/I";
sArrArgs[8] = "/YY";
sArrArgs[9] = "/PB";
sArrArgs[10] = "/H";
sArrArgs[11] = "/Q3";
sArrArgs[12] = "/k0";
sArrArgs[13] = "/VL";
Process p = Runtime.getRuntime().exec(
p.waitFor();
iRtn = p.exitValue();
http://helpdesk.objects.com.au/java/runtime-exec-locks-up
ASKER
So the code in this sample should run in a separate thread concurrent with the code I"m currently executing. Something like this?
...
sArrArgs[13] = "/VL";
StreamGobbler sg = new StreamGobbler(new InputStream(), "xx");
Thread thread = new Thread(sg);
thread.start();
Process p = Runtime.getRuntime().exec( sArrArgs);
p.waitFor();
iRtn = p.exitValue();
...
sArrArgs[13] = "/VL";
StreamGobbler sg = new StreamGobbler(new InputStream(), "xx");
Thread thread = new Thread(sg);
thread.start();
Process p = Runtime.getRuntime().exec(
p.waitFor();
iRtn = p.exitValue();
ASKER
sArrArgs[13] = "/VL";
Process p = Runtime.getRuntime().exec( sArrArgs);
StreamGobbler sg = new StreamGobbler(p.getInputSt ream(), "xx");
Thread t = new Thread(sg);
t.start();
p.waitFor();
iRtn = p.exitValue();
Process p = Runtime.getRuntime().exec(
StreamGobbler sg = new StreamGobbler(p.getInputSt
Thread t = new Thread(sg);
t.start();
p.waitFor();
iRtn = p.exitValue();
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
This works. Thanks.