aboutsummaryrefslogtreecommitdiffstats
path: root/src/sysdeps/tryprocselfexe.c
diff options
context:
space:
mode:
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 ;
+}