MCPcopy Create free account
hub / github.com/3rdparty/libprocess / IO

Class IO

include/process/subprocess.hpp:61–145  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

59 * 3. FD: Redirect to an open file descriptor.
60 */
61 class IO
62 {
63 public:
64 /**
65 * For input file descriptors a child reads from the `read` file
66 * descriptor and a parent may write to the `write` file
67 * descriptor if one is present.
68 *
69 * NOTE: We initialize `read` to -1 so that we do not close an
70 * arbitrary file descriptor, in case we encounter an error
71 * while starting a subprocess (closing -1 is always a no-op).
72 */
73 struct InputFileDescriptors
74 {
75 int_fd read = -1;
76 Option<int_fd> write = None();
77 };
78
79 /**
80 * For output file descriptors a child writes to the `write` file
81 * descriptor and a parent may read from the `read` file
82 * descriptor if one is present.
83 *
84 * NOTE: We initialize `write` to -1 so that we do not close an
85 * arbitrary file descriptor, in case we encounter an error
86 * while starting a subprocess (closing -1 is always a no-op).
87 */
88 struct OutputFileDescriptors
89 {
90 Option<int_fd> read = None();
91 int_fd write = -1;
92 };
93
94 /**
95 * Describes the lifecycle of a file descriptor passed into a subprocess
96 * via the `Subprocess::FD` helper.
97 */
98 enum FDType {
99 /**
100 * The file descriptor is duplicated before being passed to the
101 * subprocess. The original file descriptor remains open.
102 */
103 DUPLICATED,
104
105 /**
106 * The file descriptor is not duplicated before being passed to the
107 * subprocess. Upon spawning the subprocess, the original file
108 * descriptor is closed in the parent and remains open in the child.
109 */
110 OWNED
111 };
112
113
114 private:
115 friend class Subprocess;
116
117 friend Try<Subprocess> subprocess(
118 const std::string& path,

Callers 5

FDMethod · 0.85
PIPEMethod · 0.85
PATHMethod · 0.85
PIPEMethod · 0.85
PATHMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected