peerplays-fc/include/fc/process.hpp

60 lines
1.6 KiB
C++
Raw Normal View History

2012-10-26 05:03:21 +00:00
#pragma once
#include <fc/shared_impl.hpp>
#include <fc/future.hpp>
2012-12-18 19:37:14 +00:00
#include <fc/string.hpp>
2012-10-26 05:03:21 +00:00
namespace fc {
class istream;
class ostream;
class path;
template<typename> class vector;
2012-12-29 17:00:19 +00:00
fc::path find_executable_in_path( const fc::string name );
2012-10-26 05:03:21 +00:00
/**
* @brief start and manage an external process
*
* @note this class implements reference semantics.
*/
class process {
public:
enum exec_opts {
open_none = 0,
open_stdin = 0x01,
open_stdout = 0x02,
open_stderr = 0x04,
open_all = open_stdin|open_stdout|open_stderr,
};
2012-12-29 17:00:19 +00:00
2012-10-26 05:03:21 +00:00
/**
* Return a new process executing the specified exe with the specified args.
*/
fc::future<int> exec( const fc::path& exe, int opt = open_all );
fc::future<int> exec( const fc::path& exe, const fc::path& wd, int opt = open_all );
fc::future<int> exec( const fc::path& exe, fc::vector<fc::string>&& args , int opt = open_all );
fc::future<int> exec( const fc::path& exe, fc::vector<fc::string>&& args, const fc::path& wd, int opt = open_all );
/**
* Forcefully kills the process.
*/
void kill();
/**
* @brief returns a stream that writes to the process' stdin
*/
fc::ostream& in_stream();
/**
* @brief returns a stream that reads from the process' stdout
*/
fc::istream& out_stream();
/**
* @brief returns a stream that reads from the process' stderr
*/
fc::istream& err_stream();
FC_REFERENCE_TYPE(process)
};
} // namespace fc