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();
jkavxAsked:
Who is Participating?
 
objectsCommented:
yes, and another thread if you also need to swallow stderr

0
 
jkavxAuthor Commented:
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();
0
 
jkavxAuthor Commented:
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();
0
 
jkavxAuthor Commented:

This works.  Thanks.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.