BadVPN – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | include_guard "run_process_output" |
2 | |||
3 | template run_process_output { |
||
4 | alias(@_arg0) command; |
||
5 | |||
6 | # We collect the results here. |
||
7 | var(@false) succeeded; |
||
8 | value("") output; |
||
9 | |||
10 | Do { |
||
11 | # Start child process. |
||
12 | sys.start_process(command, "r", ["keep_stderr":"true"]) proc; |
||
13 | If (proc.is_error) { |
||
14 | _do->break(); |
||
15 | }; |
||
16 | |||
17 | # Get read pipe handle. |
||
18 | proc->read_pipe() read_pipe; |
||
19 | If (read_pipe.is_error) { |
||
20 | _do->break(); |
||
21 | }; |
||
22 | |||
23 | # Read all contents. |
||
24 | backtrack_point() read_again; |
||
25 | read_pipe->read() read; |
||
26 | If (read.not_eof) { |
||
27 | output->append(read); |
||
28 | read_again->go(); |
||
29 | }; |
||
30 | |||
31 | # Wait for the process to terminate. |
||
32 | proc->wait() wait; |
||
33 | val_different(wait.exit_status, "0") not_ok; |
||
34 | If (not_ok) { |
||
35 | _do->break(); |
||
36 | }; |
||
37 | |||
38 | # Assume success. |
||
39 | succeeded->set(@true); |
||
40 | }; |
||
41 | } |