Android-cuttlefish cvd tool
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
cuttlefish::process_sandboxer::PidFd Class Reference

#include <pidfd.h>

Collaboration diagram for cuttlefish::process_sandboxer::PidFd:
Collaboration graph
[legend]

Public Member Functions

int Get () const
 
absl::StatusOr< std::vector< std::pair< sapi::file_util::fileops::FDCloser, int > > > AllFds ()
 
absl::StatusOr< std::vector< std::string > > Argv ()
 
absl::StatusOr< std::vector< std::string > > Env ()
 
absl::Status HaltHierarchy ()
 
absl::Status HaltChildHierarchy ()
 

Static Public Member Functions

static absl::StatusOr< PidFdFromRunningProcess (pid_t pid)
 
static absl::StatusOr< PidFdLaunchSubprocess (absl::Span< const std::string > argv, std::vector< std::pair< sapi::file_util::fileops::FDCloser, int > > fds, absl::Span< const std::string > env)
 

Private Member Functions

 PidFd (sapi::file_util::fileops::FDCloser, pid_t)
 
absl::Status SendSignal (int signal)
 

Private Attributes

sapi::file_util::fileops::FDCloser fd_
 
pid_t pid_
 

Constructor & Destructor Documentation

◆ PidFd()

cuttlefish::process_sandboxer::PidFd::PidFd ( sapi::file_util::fileops::FDCloser  ,
pid_t   
)
private

Member Function Documentation

◆ AllFds()

absl::StatusOr< std::vector< std::pair< FDCloser, int > > > cuttlefish::process_sandboxer::PidFd::AllFds ( )

Copies file descriptors from the target process, mapping them into the current process.

Keys are file descriptor numbers in the target process, values are open file descriptors in the current process.

◆ Argv()

absl::StatusOr< std::vector< std::string > > cuttlefish::process_sandboxer::PidFd::Argv ( )

◆ Env()

absl::StatusOr< std::vector< std::string > > cuttlefish::process_sandboxer::PidFd::Env ( )

◆ FromRunningProcess()

absl::StatusOr< PidFd > cuttlefish::process_sandboxer::PidFd::FromRunningProcess ( pid_t  pid)
static

Returns a managed pidfd tracking a previously started process with pid.

Only reliably refers to the process pid if the caller can guarantee it was not reaped while this is executing, otherwise it may refer to an unknown process.

◆ Get()

int cuttlefish::process_sandboxer::PidFd::Get ( ) const

◆ HaltChildHierarchy()

absl::Status cuttlefish::process_sandboxer::PidFd::HaltChildHierarchy ( )

Halt all descendants of the process. Only safe to use if the caller guarantees the process doesn't spawn or reap any children while running.

◆ HaltHierarchy()

absl::Status cuttlefish::process_sandboxer::PidFd::HaltHierarchy ( )

Halt the process and all its descendants.

◆ LaunchSubprocess()

absl::StatusOr< PidFd > cuttlefish::process_sandboxer::PidFd::LaunchSubprocess ( absl::Span< const std::string >  argv,
std::vector< std::pair< sapi::file_util::fileops::FDCloser, int > >  fds,
absl::Span< const std::string >  env 
)
static

Launches a subprocess and returns a pidfd tracking the newly launched process.

◆ SendSignal()

absl::Status cuttlefish::process_sandboxer::PidFd::SendSignal ( int  signal)
private

Member Data Documentation

◆ fd_

sapi::file_util::fileops::FDCloser cuttlefish::process_sandboxer::PidFd::fd_
private

◆ pid_

pid_t cuttlefish::process_sandboxer::PidFd::pid_
private

The documentation for this class was generated from the following files: