mCRL2
Loading...
Searching...
No Matches
child_process.h
Go to the documentation of this file.
1// Author(s): Thomas Neele
2// Copyright: see the accompanying file COPYING or copy at
3// https://github.com/mCRL2org/mCRL2/blob/master/COPYING
4//
5// Distributed under the Boost Software License, Version 1.0.
6// (See accompanying file LICENSE_1_0.txt or copy at
7// http://www.boost.org/LICENSE_1_0.txt)
8//
9/// \file child_process.h
10
11#ifndef MCRL2_SMT_CHILD_PROCESS_H
12#define MCRL2_SMT_CHILD_PROCESS_H
13
14#include <chrono>
15#include <string>
16#include <memory>
17
18namespace mcrl2
19{
20namespace smt
21{
22
24{
25protected:
26 struct platform_impl;
27
28 std::string m_name;
29 // The declaration of the pipes requires expensive headers on Windows, so
30 // we use the pimpl idiom to hide platform dependent implementation details.
32
33 void initialize();
34
35 /**
36 * \brief Send the SIGINT signal to the child
37 */
38 void send_sigint() const;
39
40public:
41 child_process(const std::string& name)
42 : m_name(name)
43 {
45 }
46
48
49 void write(const std::string& s) const;
50
51 /**
52 * \brief Read output from the child process. This is a blocking call.
53 */
54 std::string read() const;
55
56 /**
57 * \brief Read output from the child process. If no output is available before
58 * the timeout happens, a SIGINT signal is sent to the child process and the
59 * resulting output is read and returned. NOTE: this function is not
60 * on Windows, and behaves like read()
61 */
62 std::string read(const std::chrono::microseconds& timeout) const;
63};
64
65} // namespace smt
66} // namespace mcrl2
67
68#endif // MCRL2_SMT_CHILD_PROCESS_H
Standard exception class for reporting runtime errors.
Definition exception.h:27
std::string read() const
Read output from the child process. This is a blocking call.
child_process(const std::string &name)
void send_sigint() const
Send the SIGINT signal to the child.
std::string read(const std::chrono::microseconds &timeout) const
Read output from the child process. If no output is available before the timeout happens,...
std::shared_ptr< platform_impl > m_pimpl
void write(const std::string &s) const
std::size_t operator()(const atermpp::detail::reference_aterm< T > &t) const