VeraCrypt
aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Common/Format.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/Common/Format.c b/src/Common/Format.c
index f691c78d..4363f474 100644
--- a/src/Common/Format.c
+++ b/src/Common/Format.c
@@ -1216,10 +1216,16 @@ BOOL ExternalFormatFs (int driveNo, int clusterSize, int fsType)
DWORD dwExitCode, dwWritten;
LPCSTR newLine = "\n";
- WriteFile(hChildStd_IN_Wr, (LPCVOID) newLine, 1, &dwWritten, NULL);
-
- /* wait for the format process to finish */
- WaitForSingleObject (piProcInfo.hProcess, INFINITE);
+ if (WriteFile(hChildStd_IN_Wr, (LPCVOID) newLine, 1, &dwWritten, NULL))
+ {
+ /* wait for the format process to finish */
+ WaitForSingleObject (piProcInfo.hProcess, INFINITE);
+ }
+ else
+ {
+ /* we failed to write "\n". Maybe process exited too quickly. We wait 1 second */
+ WaitForSingleObject (piProcInfo.hProcess, 1000);
+ }
/* check if it was successfull */
if (GetExitCodeProcess (piProcInfo.hProcess, &dwExitCode))