aboutsummaryrefslogtreecommitdiffstats
path: root/src/sysdeps/tryprocselfexe.c
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2025-04-02 06:02:35 +0000
committerLaurent Bercot <ska@appnovation.com>2025-04-02 06:02:35 +0000
commit200a70765a503fc94b546e5a52fdd90a59eee3b3 (patch)
tree343e317b83e45454239cdb50a50b3649bcdc174f /src/sysdeps/tryprocselfexe.c
parent56ab53289c60c6fbb06f8d548d353535d5ed1140 (diff)
downloadskalibs-200a70765a503fc94b546e5a52fdd90a59eee3b3.tar.gz
Add sagetexecname() and all the necessary infrastructure
Signed-off-by: Laurent Bercot <ska@appnovation.com>
Diffstat (limited to 'src/sysdeps/tryprocselfexe.c')
-rw-r--r--src/sysdeps/tryprocselfexe.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/sysdeps/tryprocselfexe.c b/src/sysdeps/tryprocselfexe.c
new file mode 100644
index 0000000..e8b8a88
--- /dev/null
+++ b/src/sysdeps/tryprocselfexe.c
@@ -0,0 +1,13 @@
+/* ISC license */
+
+#include <unistd.h>
+#include <stdlib.h>
+#include <errno.h>
+
+int main (int argc, char const *const *argv)
+{
+ char buf[8192] ;
+ if (argc < 2) return 111 ;
+ ssize_t r = readlink(argv[1], buf, 8192) ;
+ return r == -1 ? errno == EIO || errno == ELOOP ? 111 : 1 : r <= 1 ;
+}