commit 3d968dd52c302592398b5da327ea5d0eb4a1adfe
parent 7485aaf11a48049ca86c7964e643468804e84691
Author: Andrew Laack <andrew@laack.co>
Date: Mon, 28 Sep 2026 14:42:08 -0500
Fixed an issue where broken pipes would crash process
Diffstat:
3 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/gemini-client.cpp b/src/gemini-client.cpp
@@ -119,7 +119,6 @@ Site* GeminiClient::getNetworkedSite(Link link, std::string crtPath, std::string
Site* GeminiClient::fetchSite(Link link, std::string crtPath, std::string keyPath) {
std::string destination = link.getLinkDestination().to_string();
- // TODO: Actually handle uris
if(isPrefixed(destination, "gemini://")) {
try {
return getNetworkedSite(link, crtPath, keyPath);
diff --git a/src/main.cpp b/src/main.cpp
@@ -4,6 +4,7 @@
#include <cassert>
#include <cctype>
#include <chrono>
+#include <csignal>
#include <cstdint>
#include <ncurses.h>
#include <locale.h>
@@ -102,7 +103,6 @@ uint64_t getCurrentTime() {
}
void draw(DrawState& ds) {
-
if(COLS < 20) {
erase();
addstr("Screen width too small.");
@@ -320,6 +320,8 @@ void tryVisitSite(DrawState& ds , Browser& b, std::string site) {
int main(int argc, char** argv) {
+ std::signal(SIGPIPE, SIG_IGN); // need this in case of swapping network connections bc that shouldn't kill the whole process.
+
Browser* bPtr = new Browser{};
Browser& b = *bPtr;
diff --git a/tests/mem-leak-test.cpp b/tests/mem-leak-test.cpp
@@ -1,4 +1,5 @@
#include "../include/browser.hpp"
+#include <csignal>
#include <cstdlib>
#include <iostream>
#include <thread>
@@ -89,6 +90,7 @@ void traversal() {
// because it'll probably try to follow http links that are found.
int main() {
+ std::signal(SIGPIPE, SIG_IGN); // this is also done in main for the actual executable, this is for consistency.
std::vector<std::thread*> vec {};
for(int x = 0; x < 10; ++x) {
auto* t = new std::thread (&traversal);