Remove MCJ file for dotnet apps 10/303910/1
authorHwankyu Jhun <h.jhun@samsung.com>
Mon, 8 Jan 2024 04:21:11 +0000 (13:21 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Mon, 8 Jan 2024 04:21:11 +0000 (13:21 +0900)
The pal layer of coreclr creates the temporary file. If the process is
terminated by SIGKILL, the file is not deleted normally.
To prevent SMACK issue, the launchpad-process-pool removes the MCJ file.

Change-Id: I63eac7ee30008195ff9dcd5572b7c3222d83501b
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
src/launchpad-process-pool/signal_manager.cc
src/launchpad-process-pool/signal_manager.hh

index 51fb638..124537e 100644 (file)
@@ -53,17 +53,17 @@ class GarbageCollector : public launchpad::Worker::Job {
     }
   }
 
- void DoAtFork() {
-   _W("pid: %d", pid_);
 void DoAtFork() {
+    _W("pid: %d", pid_);
     try {
       std::string path = "/run/aul/apps/" + std::to_string(getuid()) + "/" +
-          std::to_string(pid_);
+                         std::to_string(pid_);
       DeleteSocketPath(fs::path(path));
       DeleteUnusedFiles();
     } catch (const std::filesystem::filesystem_error& e) {
       _E("Exception occurs. error(%s:%d)", e.what(), e.code().value());
     }
- }
 }
 
  private:
   void DeleteSocketPath(const fs::path& path) {
@@ -87,6 +87,19 @@ class GarbageCollector : public launchpad::Worker::Job {
   }
 
   void DeleteUnusedFiles() {
+    DeleteMCJFile();
+    DeleteTmpFiles();
+  }
+
+  void DeleteMCJFile() {
+    std::string path = "/tmp/.dotnet/mcj/MCJ.TMP." + std::to_string(pid_);
+    if (access(path.c_str(), F_OK) == 0) {
+      _W("Remove file: %s", path.c_str());
+      fs::remove(path);
+    }
+  }
+
+  void DeleteTmpFiles() {
     std::vector<std::string> files = {
         "clr-debug-pipe-" + std::to_string(pid_) + "-",
         "dotnet-diagnostic-" + std::to_string(pid_) + "-"
index 66acf22..c535ee2 100644 (file)
@@ -60,8 +60,11 @@ class SignalManager : public SigchldEvent::IEvent,
     SignalAction(int signo, struct sigaction action)
         : signo_(signo), action_(action) {}
 
-    int GetSigno() const { return signo_; };
-    struct sigaction GetSigaction() const { return action_; };
+    int GetSigno() const { return signo_; }
+
+    struct sigaction GetSigaction() const {
+      return action_;
+    }
 
    private:
     int signo_;