Skip to content

Commit

Permalink
fix: Fix crashing on new installs
Browse files Browse the repository at this point in the history
  • Loading branch information
shdwmtr committed Dec 20, 2024
1 parent 07dc66c commit 9b7e1e5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
6 changes: 3 additions & 3 deletions scripts/install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ Write-Output "${BoldPurple}++${ResetColor} If you face any issues while verifyin
Write-Output "${BoldPurple}++${ResetColor} ${BoldLightBlue}https://github.com/SteamClientHomebrew/Millennium/issues/new/choose${ResetColor}`n"

# sleep 5 seconds to allow the user to read the message
Start-Sleep -Seconds 5
# Start-Sleep -Seconds 5

Start-Steam -steamPath $steamPath

Expand All @@ -439,11 +439,11 @@ while ($pipeServer.IsConnected) {
$bytesRead = $pipeServer.Read($buffer, 0, $bufferSize)
if ($bytesRead -gt 0) {
$message = [System.Text.Encoding]::UTF8.GetString($buffer, 0, $bytesRead)
[Console]::Write($message)
# [Console]::Write($message)

# Check if the message contains "SteamUI successfully loaded"
if ($message -match "SteamUI successfully loaded!") {
Write-Host "`n${BoldGreen}++${ResetColor} Millennium has successfully loaded. Installation complete!"
Write-Host "${BoldGreen}++${ResetColor} Millennium has successfully loaded. Installation complete!"
Start-Sleep -Seconds 2
exit
}
Expand Down
18 changes: 8 additions & 10 deletions src/pipes/terminal_pipe.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,38 +15,36 @@ extern "C" {

if (hPipe == INVALID_HANDLE_VALUE)
{
std::cerr << "Failed to connect to pipe." << std::endl;
std::cerr << "Failed to connect to pipe. Error: " << GetLastError() << std::endl;
return 1;
}

int pipeDescriptor = _open_osfhandle((intptr_t)hPipe, _O_WRONLY);
if (pipeDescriptor == -1)
{
std::cerr << "Failed to get pipe file descriptor." << std::endl;
std::cerr << "Failed to get pipe file descriptor. Error: " << errno << std::endl;
CloseHandle(hPipe);
return 1;
}

FILE* pipeFile = _fdopen(pipeDescriptor, "w");
if (!pipeFile)
{
std::cerr << "Failed to open pipe file descriptor as FILE*." << std::endl;
std::cerr << "Failed to open pipe file descriptor as FILE*. Error: " << errno << std::endl;
CloseHandle(hPipe);
return 1;
}

// Redirect stdout to the named pipe
if (dup2(_fileno(pipeFile), _fileno(stdout)) == -1)
if (_dup2(_fileno(pipeFile), _fileno(stdout)) == -1)
{
std::cerr << "Failed to redirect stdout to pipe." << std::endl;
std::cerr << "Failed to redirect stdout to pipe. Error: " << errno << std::endl;
fclose(pipeFile);
CloseHandle(hPipe);
fclose(pipeFile); // Close the FILE* on failure
return 1;
}
setvbuf(stdout, NULL, _IONBF, 0);

std::shared_ptr<FILE*> pipePtr = std::make_shared<FILE*>(pipeFile);
setvbuf(stdout, NULL, _IONBF, 0);
return 0;
}
}
#endif
#endif

0 comments on commit 9b7e1e5

Please sign in to comment.