Index: src/filesystem/TempFile.php =================================================================== --- src/filesystem/TempFile.php +++ src/filesystem/TempFile.php @@ -19,6 +19,7 @@ private $dir; private $file; private $preserve; + private $ignoreRemovalFailure; private $destroyed = false; /* -( Creating a Temporary File )------------------------------------------ */ @@ -64,6 +65,21 @@ return $this; } + + /** + * Normally, failure to remove the file is considered to be an exception, which + * will fail the process with an error exit code. However, Windows loves to hold + * file locks, preventing the deletion of files. + * + * @param bool True to ignore failure removing the file. + * @return this + * @task config + */ + public function setIgnoreRemovalFailure($ignore) { + $this->ignoreRemovalFailure = $ignore; + return $this; + } + /* -( Internals )---------------------------------------------------------- */ @@ -95,14 +111,20 @@ return; } - Filesystem::remove($this->dir); + try { + @Filesystem::remove($this->dir); - // NOTE: tempnam() doesn't guarantee it will return a file inside the - // directory you passed to the function, so we make sure to nuke the file - // explicitly. - - Filesystem::remove($this->file); + // NOTE: tempnam() doesn't guarantee it will return a file inside the + // directory you passed to the function, so we make sure to nuke the file + // explicitly. + @Filesystem::remove($this->file); + } catch (Exception $ex) { + if (!$this->ignoreRemovalFailure) { + throw $ex; + } + } + $this->file = null; $this->dir = null; $this->destroyed = true; Index: src/future/exec/ExecFuture.php =================================================================== --- src/future/exec/ExecFuture.php +++ src/future/exec/ExecFuture.php @@ -706,6 +706,9 @@ if ($this->useWindowsFileStreams) { $this->windowsStdoutTempFile = new TempFile(); $this->windowsStderrTempFile = new TempFile(); + + $this->windowsStdoutTempFile->setIgnoreRemovalFailure(true); + $this->windowsStderrTempFile->setIgnoreRemovalFailure(true); $spec = array( 0 => self::$descriptorSpec[0], // stdin