@Override
 public synchronized void close(Process process) throws IOException {
   try {
     super.close(process);
   } catch (IOException e) {
     // check if we got an exception because
     // the process actually completed and we were
     // trying to flush and close it's stdin
     if (process == null || process.exitValue() != 0) {
       // the process had not terminated normally
       // throw the exception we got
       throw e;
     }
   }
 }