Link to home
Start Free TrialLog in
Avatar of jkavx
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();
Avatar of Mick Barry
Mick Barry
Flag of Australia image

Avatar of jkavx
jkavx

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();
Avatar of jkavx

ASKER

sArrArgs[13] = "/VL";
Process p = Runtime.getRuntime().exec(sArrArgs);
StreamGobbler sg = new StreamGobbler(p.getInputStream(), "xx");
Thread t = new Thread(sg);
t.start();
p.waitFor();
iRtn = p.exitValue();
ASKER CERTIFIED SOLUTION
Avatar of Mick Barry
Mick Barry
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jkavx

ASKER


This works.  Thanks.