From f4aaf7b73481248f6768302be688700a364a1af8 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Fri, 21 Mar 2025 21:45:18 -0400 Subject: [PATCH] Fix for getting age of compiler --- src/tomo.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/tomo.c b/src/tomo.c index e99f42d..93381f2 100644 --- a/src/tomo.c +++ b/src/tomo.c @@ -87,7 +87,12 @@ int main(int argc, char *argv[]) { // Get the file modification time of the compiler, so we // can recompile files after changing the compiler: - if (stat(argv[0], &compiler_stat) != 0) + char compiler_path[PATH_MAX]; + ssize_t count = readlink("/proc/self/exe", compiler_path, PATH_MAX); + if (count == -1) + err(1, "Could not find age of compiler"); + compiler_path[count] = '\0'; + if (stat(compiler_path, &compiler_stat) != 0) err(1, "Could not find age of compiler"); if (register_printf_specifier('T', printf_type, printf_pointer_size))