PageRenderTime 13ms CodeModel.GetById 9ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/vm/os-linux.cpp

http://github.com/abeaumont/factor
C++ | 27 lines | 21 code | 5 blank | 1 comment | 1 complexity | 2d60d0de62deb8f8f02395d31a6883ee MD5 | raw file
 1#include "master.hpp"
 2
 3namespace factor
 4{
 5
 6/* Snarfed from SBCL linux-so.c. You must free() the result yourself. */
 7const char *vm_executable_path()
 8{
 9	char *path = new char[PATH_MAX + 1];
10
11	int size = readlink("/proc/self/exe", path, PATH_MAX);
12	if (size < 0)
13	{
14		fatal_error("Cannot read /proc/self/exe",0);
15		return NULL;
16	}
17	else
18	{
19		path[size] = '\0';
20
21		const char *ret = safe_strdup(path);
22		delete[] path;
23		return ret;
24	}
25}
26
27}