#include <dlfcn.h>
#include <signal.h>
+#include <dirent.h>
#include <string>
#include <fstream>
return "";
}
+static void removeDebugPipe()
+{
+ DIR *dir;
+ struct dirent* entry;
+ char debugPipeFiles[PATH_MAX];;
+ sprintf(debugPipeFiles, "/tmp/clr-debug-pipe-%d-", getpid());
+
+ dir = opendir("/tmp");
+ if (dir == nullptr) {
+ _ERR("Fail to open /tmp directory");
+ return;
+ }
+
+ while ((entry = readdir(dir)) != nullptr) {
+ std::string path = concatPath("/tmp", entry->d_name);
+ if (path.find(debugPipeFiles) != std::string::npos) {
+ if (!removeFile(path)) {
+ _ERR("Fail to remove file (%s)", path.c_str());
+ }
+ }
+ }
+
+ closedir(dir);
+}
+
void preload()
{
typedef void (*PreloadDelegate)();
// preload libraries and manage dlls for optimizing startup time
preload();
+
+ // The debug pipe created in the candidate process has a "User" label.
+ // As a result, smack deny occurs when app process try to access the debug pipe.
+ // Also, since debugging is performed only in standalone mode,
+ // the debug pipe doesnot be used in the candidate process.
+ // So, to avoid smack deny error, delete unused debug pipe files.
+ removeDebugPipe();
}
__initialized = true;