From 200a70765a503fc94b546e5a52fdd90a59eee3b3 Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Wed, 2 Apr 2025 06:02:35 +0000 Subject: Add sagetexecname() and all the necessary infrastructure Signed-off-by: Laurent Bercot --- src/sysdeps/tryprocselfexe.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 src/sysdeps/tryprocselfexe.c (limited to 'src/sysdeps/tryprocselfexe.c') 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 +#include +#include + +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 ; +} -- cgit v1.3.1