Skip to content

Commit

Permalink
Improved logging of cm shell
Browse files Browse the repository at this point in the history
  • Loading branch information
SRombautsU committed Jun 17, 2024
1 parent 0bd1750 commit 5da309f
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,9 @@ static bool _StartBackgroundPlasticShell(const FString& InPathToPlasticBinary, c
verify(FPlatformProcess::CreatePipe(ShellInputPipeRead, ShellInputPipeWrite, true)); // For writing commands to cm shell child process
#endif


#if PLATFORM_WINDOWS
#if PLATFORM_WINDOWS or PLATFORM_MAC
ShellProcessHandle = FPlatformProcess::CreateProc(*InPathToPlasticBinary, *FullCommand, bLaunchDetached, bLaunchHidden, bLaunchReallyHidden, nullptr, 0, *InWorkingDirectory, ShellOutputPipeWrite, ShellInputPipeRead);
#else // PLATFORM_MAC or PLATFORM_LINUX
#else // PLATFORM_LINUX
// Update working directory
char OriginalWorkingDirectory[PATH_MAX];
getcwd(OriginalWorkingDirectory, PATH_MAX);
Expand Down Expand Up @@ -155,11 +154,13 @@ static void _ExitBackgroundCommandLineShell(const bool bInForceExit = false)
{
if (bInForceExit)
{
UE_LOG(LogSourceControl, Verbose, TEXT("_ExitBackgroundCommandLineShell: TerminateProc"));
FPlatformProcess::TerminateProc(ShellProcessHandle);
}
else
{
// Tell the 'cm shell' to exit
UE_LOG(LogSourceControl, Verbose, TEXT("_ExitBackgroundCommandLineShell: exit..."));
FPlatformProcess::WritePipe(ShellInputPipeWrite, TEXT("exit"));
// And wait up to one second for its termination
const double Timeout = 1.0;
Expand All @@ -168,14 +169,18 @@ static void _ExitBackgroundCommandLineShell(const bool bInForceExit = false)
{
if ((FPlatformTime::Seconds() - StartTimestamp) > Timeout)
{
UE_LOG(LogSourceControl, Warning, TEXT("ExitBackgroundCommandLineShell: cm shell didn't stop gracefully in %lfs."), Timeout);
UE_LOG(LogSourceControl, Warning, TEXT("_ExitBackgroundCommandLineShell: cm shell didn't stop gracefully in %lfs."), Timeout);
FPlatformProcess::TerminateProc(ShellProcessHandle);
break;
}
FPlatformProcess::Sleep(0.01f);
}
}
}
else
{
UE_LOG(LogSourceControl, Verbose, TEXT("_ExitBackgroundCommandLineShell: 'cm shell' already stopped"));
}
FPlatformProcess::CloseProc(ShellProcessHandle);
_CleanupBackgroundCommandLineShell();
}
Expand Down

0 comments on commit 5da309f

Please sign in to comment.