MCPcopy Create free account
hub / github.com/arun11299/cpp-subprocess / input

Class input

cpp-subprocess/subprocess.hpp:911–933  ·  view source on GitHub ↗

! * 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 * * Eg: input{PIPE} * OR in case of redirection, output of another Popen * input{popen.output()} */

Source from the content-addressed store, hash-verified

909 * input{popen.output()}
910 */
911struct input
912{
913 // For an already existing file descriptor.
914 explicit input(int fd): rd_ch_(fd) {}
915
916 // FILE pointer.
917 explicit input (FILE* fp):input(subprocess_fileno(fp)) { assert(fp); }
918
919 explicit input(const char* filename) {
920 int fd = subprocess_open(filename, O_RDONLY);
921 if (fd == -1) throw OSError("File not found: ", errno);
922 rd_ch_ = fd;
923 }
924 explicit input(IOTYPE typ) {
925 assert (typ == PIPE && "STDOUT/STDERR not allowed");
926#ifndef __USING_WINDOWS__
927 std::tie(rd_ch_, wr_ch_) = util::pipe_cloexec();
928#endif
929 }
930
931 int rd_ch_ = -1;
932 int wr_ch_ = -1;
933};
934
935
936/*!

Callers 1

setup_comm_channelsMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected