| 
									
										
										
										
											2009-05-02 05:04:19 -04:00
										 |  |  | #include "master.hpp"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-04 02:46:13 -04:00
										 |  |  | namespace factor | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-10-03 12:17:55 -04:00
										 |  |  | /* Snarfed from SBCL linux-so.c. You must free() the result yourself. */ | 
					
						
							| 
									
										
										
										
											2009-05-05 12:33:35 -04:00
										 |  |  | const char *vm_executable_path() | 
					
						
							| 
									
										
										
										
											2009-05-02 05:04:19 -04:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2009-09-25 22:17:20 -04:00
										 |  |  | 	char *path = new char[PATH_MAX + 1]; | 
					
						
							| 
									
										
										
										
											2009-05-02 05:04:19 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	int size = readlink("/proc/self/exe", path, PATH_MAX); | 
					
						
							|  |  |  | 	if (size < 0) | 
					
						
							|  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2009-08-25 03:20:58 -04:00
										 |  |  | 		fatal_error("Cannot read /proc/self/exe",0); | 
					
						
							| 
									
										
										
										
											2009-05-02 05:04:19 -04:00
										 |  |  | 		return NULL; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	else | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		path[size] = '\0'; | 
					
						
							| 
									
										
										
										
											2009-10-03 12:17:55 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		const char *ret = safe_strdup(path); | 
					
						
							|  |  |  | 		delete[] path; | 
					
						
							|  |  |  | 		return ret; | 
					
						
							| 
									
										
										
										
											2009-05-02 05:04:19 -04:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-04 02:46:13 -04:00
										 |  |  | } |