1 // 2 // Copyright (C) 2019 The Android Open Source Project 3 // 4 // Licensed under the Apache License, Version 2.0 (the "License"); 5 // you may not use this file except in compliance with the License. 6 // You may obtain a copy of the License at 7 // 8 // http://www.apache.org/licenses/LICENSE-2.0 9 // 10 // Unless required by applicable law or agreed to in writing, software 11 // distributed under the License is distributed on an "AS IS" BASIS, 12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 // See the License for the specific language governing permissions and 14 // limitations under the License. 15 16 #include "host/commands/run_cvd/launch/launch.h" 17 18 #if defined(CUTTLEFISH_HOST) && defined(__linux__) 19 #include <sys/prctl.h> 20 #include <sys/syscall.h> 21 #endif 22 23 #include <string> 24 25 #include "common/libs/utils/result.h" 26 #include "common/libs/utils/subprocess.h" 27 #include "host/libs/config/command_source.h" 28 #include "host/libs/config/known_paths.h" 29 30 namespace cuttlefish { 31 LogcatInfo(const CuttlefishConfig::InstanceSpecific & instance)32std::string LogcatInfo(const CuttlefishConfig::InstanceSpecific& instance) { 33 return "Logcat output: " + instance.logcat_path(); 34 } 35 LogcatReceiver(const CuttlefishConfig::InstanceSpecific & instance)36Result<MonitorCommand> LogcatReceiver( 37 const CuttlefishConfig::InstanceSpecific& instance) { 38 // Open the pipe here (from the launcher) to ensure the pipe is not deleted 39 // due to the usage counters in the kernel reaching zero. If this is not 40 // done and the logcat_receiver crashes for some reason the VMM may get 41 // SIGPIPE. 42 auto log_name = instance.logcat_pipe_name(); 43 auto cmd = Command(LogcatReceiverBinary()) 44 .AddParameter("-log_pipe_fd=", 45 CF_EXPECT(SharedFD::Fifo(log_name, 0600))); 46 MonitorCommand monitor_cmd = std::move(cmd); 47 monitor_cmd.can_sandbox = true; 48 return monitor_cmd; 49 } 50 51 } // namespace cuttlefish 52