Overview
| Artifact ID: | 57ec9c833497af6e143d29e737573c1b22984d0c |
|---|---|
| Ticket: | 1224888fffffffffffffffffffffffffffffffff
possible to have an empty info nameofexecutable |
| User & Date: | rkeene on 2009-03-21 00:59:58 |
Changes
- icomment:
This is still a problem for me. I would like TclpFindExecutable() to be more robust and look for OS-specific ways to determine the executable name. Something similar to: const char *exepaths[] = { "/proc/self/exe", "/proc/%lu/exe", "/proc/%lu/file", "/proc/%lu/object/a.out" }; char pathbuf[PATH_MAX + 1], pathbuf_copy[PATH_MAX + 1]; int pathbuf_len; int exefileexists, recursedepth, idx; if (name == NULL || *name == '\0') { /* Attempt to use "/proc/self/exe" to determine where we are */ for (idx = 0; idx < (sizeof(exepaths) / sizeof(*exepaths)); idx++) { if (strchr(exepaths[idx], '%') == NULL) { sprintf(pathbuf_copy, exepaths[idx]); } else { sprintf(pathbuf_copy, exepaths[idx], (unsigned long) getpid()); } exefileexists = access(pathbuf_copy, F_OK); if (exefileexists == 0) { for (recursedepth = 0; recursedepth < 100; recursedepth++) { pathbuf_len = readlink(pathbuf_copy, pathbuf, sizeof(pathbuf)); if (pathbuf_len < 0) { break; } if (pathbuf_len >= sizeof(pathbuf) || pathbuf_len == 0) { return; } memcpy(pathbuf_copy, pathbuf, pathbuf_len); pathbuf_copy[pathbuf_len] = '\0'; } name = pathbuf_copy; goto gotName; } } } in unix/tclUnixFile.c's TclpFindExecutable if it can't find the executable using the current methods. - login: "rkeene"
- mimetype: "text/plain"
- username: "rkeene"