SubProcessIO/SubProcessIO.h

25 lines
614 B
C++

#pragma once
#include <string>
#include <stdexcept>
class SubProcessIO
{
public:
SubProcessIO(const std::string& Command,bool TerminateOnDestruct=false) throw(std::runtime_error);
SubProcessIO(const SubProcessIO& )=delete;
~SubProcessIO();
int writeToSubProcess(const char* buffer,int szToWrite);
int peekSubProcess();
int readFromSubProcess(char* buffer,int szToRead);
int wait();
int wait(int ms);
int getExitCode();
int terminate();
void detach();
protected:
int createSubProcessWith(const std::string& Command);
private:
struct _impl;
_impl* _pimpl;
};