Check-in Number:
|
2525 | |
Date: |
2002-Aug-26 20:40:33 (local)
2002-Aug-26 18:40:33 (UTC) |
User: | rse |
Branch: | |
Comment: |
add support for /proc based determination (idea stolen by Perl's $^X) |
Tickets: |
|
Inspections: |
|
Files: |
|
ossp-pkg/path/path_self.c 1.1 -> 1.2
--- path_self.c 2002/08/23 15:33:18 1.1
+++ path_self.c 2002/08/26 18:40:33 1.2
@@ -80,6 +80,18 @@
return PATH_OK;
}
+ /* else search for /proc entries (at least possible under Linux and FreeBSD) */
+ if ((l = readlink("/proc/self/exe", res_buf, res_size-1)) == -1)
+ l = readlink("/proc/curproc/file", res_buf, res_size-1);
+ if (l > 0) {
+ if (res_buf[l-1] == '\0')
+ l--;
+ res_buf[l] = '\0';
+ if (strcmp(res_buf, "unknown") != 0)
+ if (path_resolve(res_buf, res_size, res_buf) == NULL)
+ return PATH_ERR_SYS;
+ }
+
/* else search argv[0] in $PATH */
if ((path = getenv("PATH")) == NULL)
path = PATH_DEFAULT;
|
|