Improvements from anna fork
[anna.git] / example / diameter / launcher / main.cpp
index 4f11ee2..ca439a6 100644 (file)
@@ -26,11 +26,15 @@ int main(int argc, const char** argv) {
   anna::Logger::setLevel(anna::Logger::Warning);
 
   // Current working directory and absolute trace path file:
-  char c_exe[ PATH_MAX ];
-  ssize_t count = readlink( "/proc/self/exe", c_exe, PATH_MAX );
-  std::string exe(c_exe, (count > 0) ? count : 0 );
-  std::string cwd = exe.substr(0, exe.find_last_of("/"));
-  std::string trace_file = cwd + "/launcher.trace";
+  char c_cwd[ PATH_MAX ];
+  std::string trace_file;
+  if (getcwd(c_cwd, sizeof(c_cwd)) != NULL) {
+    trace_file = c_cwd;
+    trace_file += "/launcher.trace";
+  } else {
+     perror("getcwd() error");
+     return 1;
+  }
 
   anna::Logger::initialize("launcher", new TraceWriter(trace_file.c_str(), 2048000));
   anna::time::functions::initialize(); // before application instantiation (it have a anna::time object)