diff --git a/src/linux/init/main.cpp b/src/linux/init/main.cpp index a07cc25850..827830916a 100644 --- a/src/linux/init/main.cpp +++ b/src/linux/init/main.cpp @@ -1474,7 +1474,6 @@ Return Value: --*/ -try { std::vector Variables; auto AddEnvironmentVariable = [&Variables](const char* Name, const char* Value) { @@ -1500,7 +1499,7 @@ try { THROW_LAST_ERROR_IF(TEMP_FAILURE_RETRY(dup2(SocketFd, LX_INIT_UTILITY_VM_INIT_SOCKET_FD)) < 0); - close(SocketFd); + THROW_LAST_ERROR_IF(SetCloseOnExec(SocketFd, true)); SocketFd = LX_INIT_UTILITY_VM_INIT_SOCKET_FD; } else @@ -1661,11 +1660,6 @@ try LOG_ERROR("execle({}) failed {}", LX_INIT_PATH, errno); _exit(1); } -catch (...) -{ - LOG_CAUGHT_EXCEPTION(); - _exit(1); -} void LaunchSystemDistro( int SocketFd, @@ -2381,6 +2375,7 @@ void ProcessLaunchInitMessage( } catch (...) { + LOG_CAUGHT_EXCEPTION(); ReportStatus(wil::ResultFromCaughtException()); _exit(1); } diff --git a/src/windows/service/exe/WslCoreInstance.cpp b/src/windows/service/exe/WslCoreInstance.cpp index 844f536cc9..ecfb345fa6 100644 --- a/src/windows/service/exe/WslCoreInstance.cpp +++ b/src/windows/service/exe/WslCoreInstance.cpp @@ -66,7 +66,9 @@ WslCoreInstance::WslCoreInstance( if (result.Result != 0) { // N.B. EFSBADCRC (74) or EFSCORRUPTED (117) can be returned if the disk's journal is corrupted. - if ((result.Result == EINVAL || result.Result == 74 || result.Result == 117) && result.FailureStep == LxInitCreateInstanceStepMountDisk) + // EIO (5) can be returned during LaunchInit if corruption is detected after the initial mount succeeds. + if (((result.Result == EINVAL || result.Result == 74 || result.Result == 117) && result.FailureStep == LxInitCreateInstanceStepMountDisk) || + (result.Result == 5 && result.FailureStep == LxInitCreateInstanceStepLaunchInit)) { THROW_HR(WSL_E_DISK_CORRUPTED); }