aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2025-03-21 21:45:18 -0400
committerBruce Hill <bruce@bruce-hill.com>2025-03-21 21:45:18 -0400
commitf4aaf7b73481248f6768302be688700a364a1af8 (patch)
tree6e23e4bae1b5a0c3e359d19569627382600c4c1a
parentdcf266228512e100e779fe72f2d4e9ebb605ffe6 (diff)
Fix for getting age of compiler
-rw-r--r--src/tomo.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/tomo.c b/src/tomo.c
index e99f42d9..93381f2f 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))