Merge "init: log control messages along with the process that sent them" am: 0f8a67d6a8
am: 76583e1637
am: 7ad6bed77b
Change-Id: I9722417898ea78f28901da7877dfe37f467300d3
This commit is contained in:
commit
a7e5e7a01e
|
@ -35,6 +35,7 @@
|
|||
#include <android-base/file.h>
|
||||
#include <android-base/logging.h>
|
||||
#include <android-base/properties.h>
|
||||
#include <android-base/stringprintf.h>
|
||||
#include <android-base/strings.h>
|
||||
#include <cutils/android_reboot.h>
|
||||
#include <keyutils.h>
|
||||
|
@ -63,7 +64,10 @@ using namespace std::string_literals;
|
|||
|
||||
using android::base::boot_clock;
|
||||
using android::base::GetProperty;
|
||||
using android::base::ReadFileToString;
|
||||
using android::base::StringPrintf;
|
||||
using android::base::Timer;
|
||||
using android::base::Trim;
|
||||
|
||||
namespace android {
|
||||
namespace init {
|
||||
|
@ -246,7 +250,7 @@ static const std::map<std::string, ControlMessageFunction>& get_control_message_
|
|||
return control_message_functions;
|
||||
}
|
||||
|
||||
void handle_control_message(const std::string& msg, const std::string& name) {
|
||||
void HandleControlMessage(const std::string& msg, const std::string& name, pid_t pid) {
|
||||
const auto& map = get_control_message_map();
|
||||
const auto it = map.find(msg);
|
||||
|
||||
|
@ -255,6 +259,18 @@ void handle_control_message(const std::string& msg, const std::string& name) {
|
|||
return;
|
||||
}
|
||||
|
||||
std::string cmdline_path = StringPrintf("proc/%d/cmdline", pid);
|
||||
std::string process_cmdline;
|
||||
if (ReadFileToString(cmdline_path, &process_cmdline)) {
|
||||
std::replace(process_cmdline.begin(), process_cmdline.end(), '\0', ' ');
|
||||
process_cmdline = Trim(process_cmdline);
|
||||
} else {
|
||||
process_cmdline = "unknown process";
|
||||
}
|
||||
|
||||
LOG(INFO) << "Received control message '" << msg << "' for '" << name << "' from pid: " << pid
|
||||
<< " (" << process_cmdline << ")";
|
||||
|
||||
const ControlMessageFunction& function = it->second;
|
||||
|
||||
if (function.target == ControlTarget::SERVICE) {
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
#ifndef _INIT_INIT_H
|
||||
#define _INIT_INIT_H
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
|
@ -36,7 +38,7 @@ extern std::vector<std::string> late_import_paths;
|
|||
|
||||
Parser CreateParser(ActionManager& action_manager, ServiceList& service_list);
|
||||
|
||||
void handle_control_message(const std::string& msg, const std::string& arg);
|
||||
void HandleControlMessage(const std::string& msg, const std::string& arg, pid_t pid);
|
||||
|
||||
void property_changed(const std::string& name, const std::string& value);
|
||||
|
||||
|
|
|
@ -436,7 +436,7 @@ uint32_t HandlePropertySet(const std::string& name, const std::string& value,
|
|||
return PROP_ERROR_HANDLE_CONTROL_MESSAGE;
|
||||
}
|
||||
|
||||
handle_control_message(name.c_str() + 4, value.c_str());
|
||||
HandleControlMessage(name.c_str() + 4, value, cr.pid);
|
||||
return PROP_SUCCESS;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue