2012-11-01 04:23:06 +00:00
|
|
|
#pragma once
|
2013-06-05 19:19:00 +00:00
|
|
|
#include <fc/interprocess/iprocess.hpp>
|
2012-11-01 04:23:06 +00:00
|
|
|
|
2013-06-05 19:19:00 +00:00
|
|
|
namespace fc { namespace ssh
|
|
|
|
|
{
|
2012-11-01 04:23:06 +00:00
|
|
|
|
|
|
|
|
class client;
|
|
|
|
|
|
|
|
|
|
namespace detail {
|
|
|
|
|
class process_impl;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Enables communication with a process executed via
|
|
|
|
|
* client::exec().
|
|
|
|
|
*
|
|
|
|
|
* Process can only be created by mace::ssh::client.
|
|
|
|
|
*/
|
2013-06-05 19:19:00 +00:00
|
|
|
class process : public iprocess
|
|
|
|
|
{
|
2012-11-01 04:23:06 +00:00
|
|
|
public:
|
2013-06-27 18:19:08 +00:00
|
|
|
virtual iprocess& exec( const fc::path& exe, std::vector<std::string> args,
|
2013-06-05 19:19:00 +00:00
|
|
|
const fc::path& work_dir = fc::path(), exec_opts opts = open_all );
|
2012-11-09 03:02:07 +00:00
|
|
|
|
2013-06-05 19:19:00 +00:00
|
|
|
/**
|
|
|
|
|
* Blocks until the result code of the process has been returned.
|
|
|
|
|
*/
|
|
|
|
|
virtual int result();
|
2012-11-01 04:23:06 +00:00
|
|
|
|
2012-11-12 03:04:24 +00:00
|
|
|
|
2012-11-01 04:23:06 +00:00
|
|
|
/**
|
2013-06-05 19:19:00 +00:00
|
|
|
* Not supported. libssh2 does not support sending signals to remote processes.
|
|
|
|
|
* closing in_stream() is the best you can do
|
2012-11-01 04:23:06 +00:00
|
|
|
*/
|
2013-06-05 19:19:00 +00:00
|
|
|
virtual void kill();
|
|
|
|
|
|
|
|
|
|
|
2012-11-01 04:23:06 +00:00
|
|
|
/**
|
2013-06-05 19:19:00 +00:00
|
|
|
* @brief returns a stream that writes to the process' stdin
|
2012-11-01 04:23:06 +00:00
|
|
|
*/
|
2013-06-05 19:19:00 +00:00
|
|
|
virtual fc::buffered_ostream_ptr in_stream();
|
|
|
|
|
|
2012-11-01 04:23:06 +00:00
|
|
|
/**
|
|
|
|
|
* @brief returns a stream that reads from the process' stdout
|
|
|
|
|
*/
|
2013-06-05 19:19:00 +00:00
|
|
|
virtual fc::buffered_istream_ptr out_stream();
|
2012-11-01 04:23:06 +00:00
|
|
|
/**
|
|
|
|
|
* @brief returns a stream that reads from the process' stderr
|
|
|
|
|
*/
|
2013-06-05 19:19:00 +00:00
|
|
|
virtual fc::buffered_istream_ptr err_stream();
|
2013-02-04 02:11:08 +00:00
|
|
|
|
2013-06-05 19:19:00 +00:00
|
|
|
process( fc::ssh::client_ptr c );
|
|
|
|
|
~process();
|
2012-11-01 04:23:06 +00:00
|
|
|
private:
|
2013-06-05 19:19:00 +00:00
|
|
|
std::unique_ptr<detail::process_impl> my;
|
2012-11-01 04:23:06 +00:00
|
|
|
};
|
2013-06-05 19:19:00 +00:00
|
|
|
|
2012-11-01 04:23:06 +00:00
|
|
|
} } // fc::ssh
|