diff options
author | JaeMan Park <jaeman@google.com> | 2023-07-25 11:25:29 +0900 |
---|---|---|
committer | JaeMan Park <jaeman@google.com> | 2023-07-26 13:13:50 +0900 |
commit | cf36add44a6e7968033662dd17cdca73163bd2ce (patch) | |
tree | 59932bd4f7e4d19925250edadd036f7662b3c520 | |
parent | 6381d1cd133d4149e8271d1973eb22e59526bb83 (diff) | |
download | cuttlefish-cf36add44a6e7968033662dd17cdca73163bd2ce.tar.gz |
Extract process_monitor into a library
The library can be used at other module like run_env
Test: lunch aosp_cf_x86_64_phone-userdebug && m
Change-Id: I25673393ab0ace219793b557f28bca1a4875c3ee
-rw-r--r-- | host/commands/run_cvd/Android.bp | 3 | ||||
-rw-r--r-- | host/commands/run_cvd/main.cc | 4 | ||||
-rw-r--r-- | host/commands/run_cvd/server_loop_impl.cpp | 2 | ||||
-rw-r--r-- | host/commands/run_cvd/server_loop_impl.h | 2 | ||||
-rw-r--r-- | host/libs/process_monitor/Android.bp | 43 | ||||
-rw-r--r-- | host/libs/process_monitor/process_monitor.cc (renamed from host/commands/run_cvd/process_monitor.cc) | 8 | ||||
-rw-r--r-- | host/libs/process_monitor/process_monitor.h (renamed from host/commands/run_cvd/process_monitor.h) | 0 | ||||
-rw-r--r-- | host/libs/process_monitor/process_monitor_channel.cc (renamed from host/commands/run_cvd/process_monitor_channel.cc) | 2 | ||||
-rw-r--r-- | host/libs/process_monitor/process_monitor_channel.h (renamed from host/commands/run_cvd/process_monitor_channel.h) | 0 |
9 files changed, 53 insertions, 11 deletions
diff --git a/host/commands/run_cvd/Android.bp b/host/commands/run_cvd/Android.bp index 194e15220..71873533f 100644 --- a/host/commands/run_cvd/Android.bp +++ b/host/commands/run_cvd/Android.bp @@ -41,8 +41,6 @@ cc_binary { "launch/netsim_server.cpp", "main.cc", "reporting.cpp", - "process_monitor.cc", - "process_monitor_channel.cc", "server_loop.cpp", "server_loop_impl.cpp", "server_loop_impl_snapshot.cpp", @@ -67,6 +65,7 @@ cc_binary { "libcuttlefish_host_config_fastboot", "libcuttlefish_metrics", "libcuttlefish_msg_queue", + "libcuttlefish_process_monitor", "libcuttlefish_run_cvd_proto", "libcuttlefish_utils", "libcuttlefish_vm_manager", diff --git a/host/commands/run_cvd/main.cc b/host/commands/run_cvd/main.cc index 5a85f5683..84db1a752 100644 --- a/host/commands/run_cvd/main.cc +++ b/host/commands/run_cvd/main.cc @@ -35,19 +35,19 @@ #include "common/libs/utils/tee_logging.h" #include "host/commands/run_cvd/boot_state_machine.h" #include "host/commands/run_cvd/launch/launch.h" -#include "host/commands/run_cvd/process_monitor.h" #include "host/commands/run_cvd/reporting.h" #include "host/commands/run_cvd/runner_defs.h" #include "host/commands/run_cvd/server_loop.h" #include "host/commands/run_cvd/validate.h" #include "host/libs/config/adb/adb.h" -#include "host/libs/config/fastboot/fastboot.h" #include "host/libs/config/config_flag.h" #include "host/libs/config/config_fragment.h" #include "host/libs/config/custom_actions.h" #include "host/libs/config/cuttlefish_config.h" +#include "host/libs/config/fastboot/fastboot.h" #include "host/libs/config/inject.h" #include "host/libs/metrics/metrics_receiver.h" +#include "host/libs/process_monitor/process_monitor.h" #include "host/libs/vm_manager/vm_manager.h" namespace cuttlefish { diff --git a/host/commands/run_cvd/server_loop_impl.cpp b/host/commands/run_cvd/server_loop_impl.cpp index 2953e1e71..80177d886 100644 --- a/host/commands/run_cvd/server_loop_impl.cpp +++ b/host/commands/run_cvd/server_loop_impl.cpp @@ -32,13 +32,13 @@ #include "common/libs/utils/files.h" #include "common/libs/utils/result.h" #include "common/libs/utils/subprocess.h" -#include "host/commands/run_cvd/process_monitor.h" #include "host/commands/run_cvd/runner_defs.h" #include "host/libs/command_util/util.h" #include "host/libs/config/command_source.h" #include "host/libs/config/cuttlefish_config.h" #include "host/libs/config/data_image.h" #include "host/libs/config/inject.h" +#include "host/libs/process_monitor/process_monitor.h" namespace cuttlefish { namespace run_cvd_impl { diff --git a/host/commands/run_cvd/server_loop_impl.h b/host/commands/run_cvd/server_loop_impl.h index 57136c4d8..b9e940113 100644 --- a/host/commands/run_cvd/server_loop_impl.h +++ b/host/commands/run_cvd/server_loop_impl.h @@ -25,7 +25,6 @@ #include "common/libs/fs/shared_fd.h" #include "common/libs/utils/result.h" -#include "host/commands/run_cvd/process_monitor.h" #include "host/commands/run_cvd/runner_defs.h" #include "host/commands/run_cvd/server_loop.h" #include "host/libs/command_util/util.h" @@ -33,6 +32,7 @@ #include "host/libs/config/cuttlefish_config.h" #include "host/libs/config/feature.h" #include "host/libs/config/inject.h" +#include "host/libs/process_monitor/process_monitor.h" namespace cuttlefish { namespace run_cvd_impl { diff --git a/host/libs/process_monitor/Android.bp b/host/libs/process_monitor/Android.bp new file mode 100644 index 000000000..97ab93d43 --- /dev/null +++ b/host/libs/process_monitor/Android.bp @@ -0,0 +1,43 @@ +// +// Copyright (C) 2023 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package { + default_applicable_licenses: ["Android-Apache-2.0"], +} + +cc_library_static { + name: "libcuttlefish_process_monitor", + srcs: [ + "process_monitor.cc", + "process_monitor_channel.cc" + ], + shared_libs: [ + "libcuttlefish_fs", + "libcuttlefish_utils", + "libbase", + "libfruit", + "libjsoncpp", + ], + static_libs: [ + "libcuttlefish_host_config", + "libgflags", + ], + target: { + darwin: { + enabled: true, + }, + }, + defaults: ["cuttlefish_host"], +} diff --git a/host/commands/run_cvd/process_monitor.cc b/host/libs/process_monitor/process_monitor.cc index aa98d4bd0..1d54fa42f 100644 --- a/host/commands/run_cvd/process_monitor.cc +++ b/host/libs/process_monitor/process_monitor.cc @@ -14,7 +14,7 @@ * limitations under the License. */ -#include "host/commands/run_cvd/process_monitor.h" +#include "host/libs/process_monitor/process_monitor.h" #ifdef __linux__ #include <sys/prctl.h> @@ -43,9 +43,9 @@ #include "common/libs/fs/shared_select.h" #include "common/libs/utils/result.h" #include "common/libs/utils/subprocess.h" -#include "host/commands/run_cvd/process_monitor_channel.h" #include "host/libs/config/cuttlefish_config.h" #include "host/libs/config/known_paths.h" +#include "host/libs/process_monitor/process_monitor_channel.h" namespace cuttlefish { @@ -100,8 +100,8 @@ Result<void> MonitorLoop(const std::atomic_bool& running, int error_num = errno; CF_EXPECT(pid != -1, "Wait failed: " << strerror(error_num)); if (!WIFSIGNALED(wstatus) && !WIFEXITED(wstatus)) { - LOG(DEBUG) << "Unexpected status from wait: " << wstatus - << " for pid " << pid; + LOG(DEBUG) << "Unexpected status from wait: " << wstatus << " for pid " + << pid; continue; } if (!running.load()) { // Avoid extra restarts near the end diff --git a/host/commands/run_cvd/process_monitor.h b/host/libs/process_monitor/process_monitor.h index ca951607a..ca951607a 100644 --- a/host/commands/run_cvd/process_monitor.h +++ b/host/libs/process_monitor/process_monitor.h diff --git a/host/commands/run_cvd/process_monitor_channel.cc b/host/libs/process_monitor/process_monitor_channel.cc index eddecb0bf..3b802b242 100644 --- a/host/commands/run_cvd/process_monitor_channel.cc +++ b/host/libs/process_monitor/process_monitor_channel.cc @@ -14,7 +14,7 @@ * limitations under the License. */ -#include "host/commands/run_cvd/process_monitor_channel.h" +#include "host/libs/process_monitor/process_monitor_channel.h" #include <string> diff --git a/host/commands/run_cvd/process_monitor_channel.h b/host/libs/process_monitor/process_monitor_channel.h index 1d5e544d5..1d5e544d5 100644 --- a/host/commands/run_cvd/process_monitor_channel.h +++ b/host/libs/process_monitor/process_monitor_channel.h |