CBMC
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
piped_process.h
Go to the documentation of this file.
1
4
5#ifndef CPROVER_UTIL_PIPED_PROCESS_H
6#define CPROVER_UTIL_PIPED_PROCESS_H
7
8#ifdef _WIN32
9# include <memory>
10// The below are forward declarations for Windows APIs
11struct _PROCESS_INFORMATION; // NOLINT
12typedef struct _PROCESS_INFORMATION PROCESS_INFORMATION; // NOLINT
13typedef void *HANDLE; // NOLINT
14#endif
15
16#include "message.h"
17
18#include <vector>
19
20#define PIPED_PROCESS_INFINITE_TIMEOUT \
21 std::optional<std::size_t> \
22 { \
23 }
24
26{
27public:
29 enum class statet
30 {
31 RUNNING,
33 };
34
36 enum class send_responset
37 {
39 FAILED,
41 };
42
46 [[nodiscard]] send_responset send(const std::string &message);
49 std::string receive();
53 std::string wait_receive();
54
58
65 bool can_receive(std::optional<std::size_t> wait_time);
66
70 bool can_receive();
71
76 // of can_receive(0)
77 void wait_receivable(int wait_time);
78
83 explicit piped_processt(
84 const std::vector<std::string> &commandvec,
85 message_handlert &message_handler);
86
87 // Deleted due to declaring an explicit destructor and not wanting copy
88 // constructors to be implemented.
89 piped_processt(const piped_processt &) = delete;
92
93protected:
94#ifdef _WIN32
95 // Process information handle for Windows
96 std::unique_ptr<PROCESS_INFORMATION> proc_info;
97 // Handles for communication with child process
102#else
103 // Child process ID.
106 // The member fields below are so named from the perspective of the
107 // parent -> child process. So `pipe_input` is where we are feeding
108 // commands to the child process, and `pipe_output` is where we read
109 // the results of execution from.
112#endif
115};
116
117#endif // endifndef CPROVER_UTIL_PIPED_PROCESS_H
ait supplies three of the four components needed: an abstract interpreter (in this case handling func...
Definition ai.h:562
ait()
Definition ai.h:565
Class that provides messages with a built-in verbosity 'level'.
Definition message.h:154
bool can_receive()
See if this process can receive data from the other process.
void wait_receivable(int wait_time)
Wait for the pipe to be ready, waiting specified time between checks.
piped_processt(const piped_processt &)=delete
std::string receive()
Read a string from the child process' output.
send_responset send(const std::string &message)
Send a string message (command) to the child process.
piped_processt & operator=(const piped_processt &)=delete
statet
Enumeration to keep track of child process state.
statet get_status()
Get child process status.
send_responset
Enumeration for send response.
std::string wait_receive()
Wait until a string is available and read a string from the child process' output.
unsigned int statet