Version 1 (modified by 17 years ago) (diff) | ,
---|
SocLib Components General Index
Component description
This component is a common utility component.
This creates a wrapper to a process. The wrapped process will be executed with the simulator, wrapping code may:
- read stdout from wrapped process
- poll stdout from wrapped process
- write to wrapped process' stdin
- send signals to wrapped process
Component usage
Object
soclib::common::ProcessWrapper *process;
Instanciation
soclib::common::ProcessWrapper( const std::string &cmd, const std::vector<std::string> &argv );
- cmd
- The command to launch, it will be looked for in $PATH
- argv
- The argv in a standart unix style. argv[0] should look like cmd.
Usage
std::vector<std::string> argv; argv.push_back("date"); argv.push_back("+%s"); soclib::common::ProcessWrapper process("date", argv); char buffer[128]; process.read( buffer, 128 ); std::cout << "Date is " << buffer << " seconds since EPOCH" << std::endl;