Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fdd861ef authored by T.J. Mercier's avatar T.J. Mercier
Browse files

debuggerd: Use libprocessgroup to unfreeze

Cgroup v2 paths are owned by libprocessgroup. Those paths can change
based on build flags, so paths generated outside of libprocessgroup may
not always be correct.

Bug: 382693152
Test: adb shell debuggerd -b <pid>
Change-Id: I7e486ab6f4068d0fae1be033a91b9a307f54ed42
parent 1de1f1d8
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -505,6 +505,7 @@ cc_binary {
        "libbase",
        "libdebuggerd_client",
        "liblog",
        "libprocessgroup",
        "libprocinfo",
    ],

+3 −8
Original line number Diff line number Diff line
@@ -23,11 +23,11 @@
#include <string_view>
#include <thread>

#include <android-base/file.h>
#include <android-base/logging.h>
#include <android-base/parseint.h>
#include <android-base/unique_fd.h>
#include <debuggerd/client.h>
#include <processgroup/processgroup.h>
#include <procinfo/process.h>
#include "util.h"

@@ -92,13 +92,8 @@ int main(int argc, char* argv[]) {
  }

  // unfreeze if pid is frozen.
  const std::string freeze_file = android::base::StringPrintf(
      "/sys/fs/cgroup/uid_%d/pid_%d/cgroup.freeze", proc_info.uid, proc_info.pid);
  if (std::string freeze_status;
      android::base::ReadFileToString(freeze_file, &freeze_status) && freeze_status[0] == '1') {
    android::base::WriteStringToFile("0", freeze_file);
  SetProcessProfiles(proc_info.uid, proc_info.pid, {"Unfrozen"});
  // we don't restore the frozen state as this is considered a benign change.
  }

  unique_fd output_fd(fcntl(STDOUT_FILENO, F_DUPFD_CLOEXEC, 0));
  if (output_fd.get() == -1) {