From 349478aa6b46553355dd6879114fccce03748ae0 Mon Sep 17 00:00:00 2001 From: Ralph Sennhauser Date: Sat, 20 Dec 2025 14:00:13 +0100 Subject: [PATCH] Remove Linux sys_ExecutablePathname fallback The fallback is of little value and blocks making cxxtest an optional build dependency. While at it use realpath instead of readlink. Refs: #8618 Signed-off-by: Ralph Sennhauser --- source/lib/sysdep/os/linux/linux.cpp | 32 +++++---------------------- source/lib/sysdep/tests/test_sysdep.h | 2 +- 2 files changed, 6 insertions(+), 28 deletions(-) diff --git a/source/lib/sysdep/os/linux/linux.cpp b/source/lib/sysdep/os/linux/linux.cpp index 44e9afc61b..2bb6d5ed1f 100644 --- a/source/lib/sysdep/os/linux/linux.cpp +++ b/source/lib/sysdep/os/linux/linux.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2025 Wildfire Games. +/* Copyright (C) 2026 Wildfire Games. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the @@ -23,37 +23,15 @@ #include "precompiled.h" #include "lib/os_path.h" -#include "lib/posix/posix_types.h" -#include "lib/sysdep/os/unix/unix_executable_pathname.h" #include "lib/sysdep/sysdep.h" #include -#include - -static bool getPathFromProc(char* buffer, size_t length) -{ - int pos = readlink("/proc/self/exe", buffer, length-1); - if (pos <= 0) - return false; - - buffer[pos] = '\0'; - - char* endOfPath = strrchr(buffer, '/'); - if (endOfPath == NULL) - return false; - - ++endOfPath; - *endOfPath = '\0'; - - return true; -} +#include OsPath sys_ExecutablePathname() { - // Check /proc for the path char pathBuffer[PATH_MAX]; - if (getPathFromProc(pathBuffer, sizeof(pathBuffer))) - return pathBuffer; - - return unix_ExecutablePathname(); + if (realpath("/proc/self/exe", pathBuffer) == nullptr) + return {}; + return pathBuffer; } diff --git a/source/lib/sysdep/tests/test_sysdep.h b/source/lib/sysdep/tests/test_sysdep.h index 5ed9b1f8cc..a217f30d7f 100644 --- a/source/lib/sysdep/tests/test_sysdep.h +++ b/source/lib/sysdep/tests/test_sysdep.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2025 Wildfire Games. +/* Copyright (C) 2026 Wildfire Games. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the