File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change
1
+ # ` src/util/piped_process.{cpp, h} `
2
+
3
+ To utilise the ` piped_process ` API for interprocess communication with any binary:
4
+
5
+ * You need to initialise it by calling the construct ` piped_processt("binary with args") ` .
6
+ * If IPC fails before child process creation, you will get a ` system_exceptiont ` .
7
+ * If the ` binary command ` does not correspond to a binary in the ` $PATH ` or is
8
+ not a path to a binary itself, you'll read a string ` Launching <xyz> failed with error: <error> `
9
+ when you attempt to ` receive() ` output from the child process.
10
+ * The child process is automatically killed with SIGTERM when the destructor for
11
+ the ` piped_processt ` object is called.
12
+ * This will occur automatically when the ` piped_processt ` goes out of scope if
13
+ it's locally scoped.
14
+ * Use ` send() ` to send a string message to the child process' input.
15
+ * This returns a ` send_responset ` , an enum that shows whether the
16
+ sending of the message through the pipe succeeded or failed.
17
+ * Use ` receive() ` to read a string message from the child process' output.
18
+ * It's always a good idea to guard a call to ` receive ` with ` can_receive() ` ,
19
+ so that receiving is blocked until there's something to receive.
20
+ * ` can_receive ` with no arguments will default to infinite wait time for piped
21
+ process readiness.
22
+ * Alternatively, you can guard the call to ` receive ` with ` wait_receivable ` .
23
+ ` wait_receivable ` takes an integer value representing ` microseconds ` of waiting
24
+ time between checks for pipe readiness.
You can’t perform that action at this time.
0 commit comments