Getting started with reading this source code. The source is mainly divided into four parts: 1. Exception Classes: These are very basic exception classes derived from runtime_error exception. There are two types of exception thrown from subprocess library: OSError and CalledProcessError

Description

2. Popen Class This is the main class the users will deal with. It provides with all the API's to deal with processes.

3. Util namespace It includes some helper functions to split/join a string, reading from file descriptors, waiting on a process, fcntl options on file descriptors etc.

4. Detail namespace This includes some metaprogramming and helper classes.

Namespaces

Name

Description

util

Low‐level helpers shared by the subprocess implementation (argument quoting, pipes, descriptors).

Types

Name

Description

Buffer

class: Buffer This class is a very thin wrapper around std::vector<char> This is basically used to determine the length of the actual data stored inside the dynamically resized vector.

CalledProcessError

class: CalledProcessError Thrown when there was error executing the command. Check Popen class API's to know when this exception can be thrown.

OSError

class: OSError Thrown when some system call fails to execute or give result. The exception message contains the name of the failed system call with the stringisized errno code. Check Popen class API's to know when this exception would be thrown. Its usual that the API exception specification would have this exception together with CalledProcessError.

Popen

class: Popen This is the single most important class in the whole library and glues together all the helper classes to provide a common interface to the client.

error

Option to specify the error channel for the child process. It can be: 1. An already open file descriptor. 2. A file name. 3. IOTYPE. Usually a PIPE or STDOUT

executable

Option to specify the executable name separately from the args sequence. In this case the cmd args must only contain the options required for this executable.

input

Option to specify the input channel for the child process. It can be: 1. An already open file descriptor. 2. A file name. 3. IOTYPE. Usual a PIPE

output

Option to specify the output channel for the child process. It can be: 1. An already open file descriptor. 2. A file name. 3. IOTYPE. Usually a PIPE.

string_arg

Base class for all arguments involving string value.

Type Aliases

Name

Description

ErrBuffer

Buffer holding the data captured from the child's error descriptor.

OutBuffer

Buffer holding the data captured from the child's output descriptor.

Enums

Name

Description

IOTYPE

Used for redirecting input/output/error

Variables

Name

Description

DEFAULT_BUF_CAP_BYTES

Default buffer capacity for OutBuffer and ErrBuffer, in bytes.

SP_MAX_ERR_BUF_SIZ

Maximum buffer size allocated on the stack when reading an error from a pipe.

Created with MrDocs