foreseen

A text-based gemini browser with prefetching.
git clone git://git.laack.co/foreseen.git
Log | Files | Refs | README | LICENSE

commit 35940c6515829da9a8e12fa873d8325c2f847c6e
parent 9071412907db08cb2ab95f33156724b8e04ef1ce
Author: Andrew Laack <andrew@laack.co>
Date:   Thu, 24 Sep 2026 23:29:25 -0500

Don't allow xdg-open to much up stdout

Diffstat:
Msrc/utils.cpp | 12++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/src/utils.cpp b/src/utils.cpp @@ -9,7 +9,6 @@ #include "../include/preformatted.hpp" #include <cassert> #include <cstddef> -#include <cstdint> #include <cstdlib> #include <fstream> #include <iomanip> @@ -23,15 +22,24 @@ #include <vector> #include <spawn.h> #include <sys/wait.h> +#include <fcntl.h> extern char** environ; void openUrl(const std::string& url) { + + posix_spawn_file_actions_t fa; + posix_spawn_file_actions_init(&fa); + // we don't want the stdout mucking up our terminal. + posix_spawn_file_actions_addopen(&fa, 1, "/dev/null", O_WRONLY, 0); + posix_spawn_file_actions_adddup2(&fa, 1, 2); + pid_t pid; char* argv[] = {(char*)"xdg-open", (char*)url.c_str(), nullptr}; - if (posix_spawnp(&pid, "xdg-open", nullptr, nullptr, argv, environ) == 0) { + if (posix_spawnp(&pid, "xdg-open", &fa, nullptr, argv, environ) == 0) { waitpid(pid, nullptr, 0); } + posix_spawn_file_actions_destroy(&fa); } bool isPrefixed(std::string input, std::string prefix) {