[#subprocess]
= subprocess
:mrdocs:

Getting started with reading this source code&period; The source is mainly divided into four parts&colon; 1&period; Exception Classes&colon; These are very basic exception classes derived from runtime&lowbar;error exception&period; There are two types of exception thrown from subprocess library&colon; OSError and CalledProcessError

== Description

2&period; Popen Class This is the main class the users will deal with&period; It provides with all the API&apos;s to deal with processes&period;

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

4&period; Detail namespace This includes some metaprogramming and helper classes&period;

== Namespaces

[cols="1,4"]
|===
| Name| Description
| xref:subprocess/util.adoc[`util`] 
| Low&hyphen;level helpers shared by the subprocess implementation (argument quoting, pipes, descriptors)&period;
|===


== Types

[cols="1,4"]
|===
| Name| Description
| xref:subprocess/Buffer.adoc[`Buffer`] 
| class&colon; Buffer This class is a very thin wrapper around std&colon;&colon;vector&lt;char&gt; This is basically used to determine the length of the actual data stored inside the dynamically resized vector&period;
| xref:subprocess/CalledProcessError.adoc[`CalledProcessError`] 
| class&colon; CalledProcessError Thrown when there was error executing the command&period; Check Popen class API&apos;s to know when this exception can be thrown&period;
| xref:subprocess/OSError.adoc[`OSError`] 
| class&colon; OSError Thrown when some system call fails to execute or give result&period; The exception message contains the name of the failed system call with the stringisized errno code&period; Check Popen class API&apos;s to know when this exception would be thrown&period; Its usual that the API exception specification would have this exception together with CalledProcessError&period;
| xref:subprocess/Popen.adoc[`Popen`] 
| class&colon; 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&period;
| xref:subprocess/error.adoc[`error`] 
| Option to specify the error channel for the child process&period; It can be&colon; 1&period; An already open file descriptor&period; 2&period; A file name&period; 3&period; IOTYPE&period; Usually a PIPE or STDOUT
| xref:subprocess/executable.adoc[`executable`] 
| Option to specify the executable name separately from the args sequence&period; In this case the cmd args must only contain the options required for this executable&period;
| xref:subprocess/input.adoc[`input`] 
| Option to specify the input channel for the child process&period; It can be&colon; 1&period; An already open file descriptor&period; 2&period; A file name&period; 3&period; IOTYPE&period; Usual a PIPE
| xref:subprocess/output.adoc[`output`] 
| Option to specify the output channel for the child process&period; It can be&colon; 1&period; An already open file descriptor&period; 2&period; A file name&period; 3&period; IOTYPE&period; Usually a PIPE&period;
| xref:subprocess/string_arg.adoc[`string&lowbar;arg`] 
| Base class for all arguments involving string value&period;
|===


== Type Aliases

[cols="1,4"]
|===
| Name| Description
| xref:subprocess/ErrBuffer.adoc[`ErrBuffer`] 
| Buffer holding the data captured from the child&apos;s error descriptor&period;
| xref:subprocess/OutBuffer.adoc[`OutBuffer`] 
| Buffer holding the data captured from the child&apos;s output descriptor&period;
|===


== Enums

[cols="1,4"]
|===
| Name| Description
| xref:subprocess/IOTYPE.adoc[`IOTYPE`] 
| Used for redirecting input&sol;output&sol;error
|===


== Variables

[cols="1,4"]
|===
| Name| Description
| xref:subprocess/DEFAULT_BUF_CAP_BYTES.adoc[`DEFAULT&lowbar;BUF&lowbar;CAP&lowbar;BYTES`] 
| Default buffer capacity for OutBuffer and ErrBuffer, in bytes&period;
| xref:subprocess/SP_MAX_ERR_BUF_SIZ.adoc[`SP&lowbar;MAX&lowbar;ERR&lowbar;BUF&lowbar;SIZ`] 
| Maximum buffer size allocated on the stack when reading an error from a pipe&period;
|===



[.small]#Created with https://www.mrdocs.com[MrDocs]#
