LLDB  mainline
HostProcessPosix.cpp
Go to the documentation of this file.
1 //===-- HostProcessPosix.cpp ----------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #include "lldb/Host/Host.h"
10 #include "lldb/Host/FileSystem.h"
12 
13 #include "llvm/ADT/STLExtras.h"
14 
15 #include <climits>
16 #include <csignal>
17 #include <unistd.h>
18 
19 using namespace lldb_private;
20 
21 static const int kInvalidPosixProcess = 0;
22 
25 
27  : HostNativeProcessBase(process) {}
28 
30 
31 Status HostProcessPosix::Signal(int signo) const {
33  Status error;
34  error.SetErrorString("HostProcessPosix refers to an invalid process");
35  return error;
36  }
37 
38  return HostProcessPosix::Signal(m_process, signo);
39 }
40 
42  Status error;
43 
44  if (-1 == ::kill(process, signo))
45  error.SetErrorToErrno();
46 
47  return error;
48 }
49 
51 
53 
56  return false;
57 
58  // Send this process the null signal. If it succeeds the process is running.
59  Status error = Signal(0);
60  return error.Success();
61 }
62 
63 llvm::Expected<HostThread> HostProcessPosix::StartMonitoring(
64  const Host::MonitorChildProcessCallback &callback) {
66 }
kInvalidPosixProcess
static const int kInvalidPosixProcess
Definition: HostProcessPosix.cpp:21
FileSystem.h
lldb_private::HostProcessPosix::HostProcessPosix
HostProcessPosix()
Definition: HostProcessPosix.cpp:23
Host.h
lldb_private::HostProcessPosix::IsRunning
bool IsRunning() const override
Definition: HostProcessPosix.cpp:54
lldb_private::Host::MonitorChildProcessCallback
std::function< void(lldb::pid_t pid, int signal, int status)> MonitorChildProcessCallback
Definition: Host.h:68
error
static llvm::raw_ostream & error(Stream &strm)
Definition: CommandReturnObject.cpp:17
HostProcessPosix.h
SIGKILL
#define SIGKILL
Definition: windows/PosixApi.h:31
lldb_private::HostProcessPosix::GetProcessId
lldb::pid_t GetProcessId() const override
Definition: HostProcessPosix.cpp:52
lldb_private::HostProcessPosix::StartMonitoring
llvm::Expected< HostThread > StartMonitoring(const Host::MonitorChildProcessCallback &callback) override
Definition: HostProcessPosix.cpp:63
lldb_private::Host::StartMonitoringChildProcess
static llvm::Expected< HostThread > StartMonitoringChildProcess(const MonitorChildProcessCallback &callback, lldb::pid_t pid)
Start monitoring a child process.
Definition: common/Host.cpp:98
lldb_private::Status
Definition: Status.h:44
lldb_private::HostProcessPosix::~HostProcessPosix
~HostProcessPosix() override
lldb::pid_t
uint64_t pid_t
Definition: lldb-types.h:85
lldb::process_t
uint64_t process_t
Definition: lldb-types.h:57
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb_private::HostProcessPosix::Signal
virtual Status Signal(int signo) const
Definition: HostProcessPosix.cpp:31
lldb_private::HostProcessPosix::Terminate
Status Terminate() override
Definition: HostProcessPosix.cpp:50
lldb_private::HostNativeProcessBase
Definition: HostNativeProcessBase.h:21
lldb_private::HostNativeProcessBase::m_process
lldb::process_t m_process
Definition: HostNativeProcessBase.h:43