aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/runtime/commands/CleanCommand.java
diff options
context:
space:
mode:
authorGravatar Laszlo Csomor <laszlocsomor@google.com>2017-06-12 09:39:10 +0200
committerGravatar Yun Peng <pcloudy@google.com>2017-06-12 11:22:32 +0200
commit70ff798abb013ef66fca651e8cfa6c6aea96460b (patch)
treeb56869fac1aaf032e3cecd9b08b07b51d33c5b3d /src/main/java/com/google/devtools/build/lib/runtime/commands/CleanCommand.java
parentb1b02d70a16f34955863d93f80698369203edded (diff)
Windows: bazel clean --expunge works
Fixes https://github.com/bazelbuild/bazel/issues/1586 Fixes https://github.com/bazelbuild/bazel/issues/2326 This change also undoes https://github.com/bazelbuild/bazel/commit/956810b6ee24289e457a4b8d0a84ff56eb32c264 -- since Bazel now closes its stdout/stderr before cleaning, jvm.out is also closed so we don't need to open it with deletion sharing. RELNOTES: Windows: bazel clean --expunge works Change-Id: I692f2e86a5983cb472a142a093611fd1c694cd3b PiperOrigin-RevId: 158682987
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/runtime/commands/CleanCommand.java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/runtime/commands/CleanCommand.java15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/runtime/commands/CleanCommand.java b/src/main/java/com/google/devtools/build/lib/runtime/commands/CleanCommand.java
index 93952a1825..352c19635e 100644
--- a/src/main/java/com/google/devtools/build/lib/runtime/commands/CleanCommand.java
+++ b/src/main/java/com/google/devtools/build/lib/runtime/commands/CleanCommand.java
@@ -34,7 +34,10 @@ import com.google.devtools.common.options.Option;
import com.google.devtools.common.options.OptionsBase;
import com.google.devtools.common.options.OptionsParser;
import com.google.devtools.common.options.OptionsProvider;
+import java.io.FileDescriptor;
+import java.io.FileOutputStream;
import java.io.IOException;
+import java.util.logging.LogManager;
import java.util.logging.Logger;
/** Implements 'blaze clean'. */
@@ -227,6 +230,18 @@ public final class CleanCommand implements BlazeCommand {
if (expunge) {
LOG.info("Expunging...");
env.getRuntime().prepareForAbruptShutdown();
+ // Close java.log.
+ LogManager.getLogManager().reset();
+ // Close the default stdout/stderr.
+ if (FileDescriptor.out.valid()) {
+ new FileOutputStream(FileDescriptor.out).close();
+ }
+ if (FileDescriptor.err.valid()) {
+ new FileOutputStream(FileDescriptor.err).close();
+ }
+ // Close the redirected stdout/stderr.
+ System.out.close();
+ System.err.close();
// Delete the big subdirectories with the important content first--this
// will take the most time. Then quickly delete the little locks, logs
// and links right before we exit. Once the lock file is gone there will