]> gitweb.factorcode.org Git - factor.git/blob - vm/os-linux.cpp
VM: Refactor os-* to Factor style
[factor.git] / vm / os-linux.cpp
1 #include "master.hpp"
2
3 namespace factor {
4
5 /* Snarfed from SBCL linux-so.c. You must free() the result yourself. */
6 const char* vm_executable_path() {
7   char* path = new char[PATH_MAX + 1];
8
9   int size = readlink("/proc/self/exe", path, PATH_MAX);
10   if (size < 0) {
11     fatal_error("Cannot read /proc/self/exe", 0);
12     return NULL;
13   } else {
14     path[size] = '\0';
15
16     const char* ret = safe_strdup(path);
17     delete[] path;
18     return ret;
19   }
20 }
21
22 }