| 824 | } |
| 825 | |
| 826 | bool chdir_to_bindir() |
| 827 | { |
| 828 | #ifdef LINUX |
| 829 | char rgchPath[PATH_MAX], *pchPathTail; |
| 830 | memset(rgchPath, 0, sizeof(rgchPath)); |
| 831 | |
| 832 | if (readlink("/proc/self/exe", rgchPath, sizeof(rgchPath)) == -1) |
| 833 | return false; |
| 834 | |
| 835 | pchPathTail = strrchr(rgchPath, '/'); |
| 836 | if (!pchPathTail) |
| 837 | return false; |
| 838 | |
| 839 | *pchPathTail = 0; |
| 840 | if (chdir(rgchPath) == -1) |
| 841 | return false; |
| 842 | #endif |
| 843 | return true; |
| 844 | } |
| 845 | |
| 846 | int main() |
| 847 | { |