MCPcopy Create free account
hub / github.com/ElementsProject/lightning / create_child

Function create_child

ccan/ccan/ptr_valid/ptr_valid.c:202–237  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

200}
201
202static bool create_child(struct ptr_valid_batch *batch)
203{
204 int outpipe[2], inpipe[2];
205
206 if (pipe(outpipe) != 0)
207 return false;
208 if (pipe(inpipe) != 0)
209 goto close_outpipe;
210
211 fflush(stdout);
212 batch->child_pid = fork();
213 if (batch->child_pid == 0) {
214 close(outpipe[1]);
215 close(inpipe[0]);
216 run_child(outpipe[0], inpipe[1]);
217 }
218
219 if (batch->child_pid == -1)
220 goto cleanup_pid;
221
222 close(outpipe[0]);
223 close(inpipe[1]);
224
225 batch->to_child = outpipe[1];
226 batch->from_child = inpipe[0];
227 return true;
228
229cleanup_pid:
230 batch->child_pid = 0;
231 close_noerr(inpipe[0]);
232 close_noerr(inpipe[1]);
233close_outpipe:
234 close_noerr(outpipe[0]);
235 close_noerr(outpipe[1]);
236 return false;
237}
238
239static bool check_with_child(struct ptr_valid_batch *batch,
240 const void *p, size_t size, bool is_write)

Callers 1

check_with_childFunction · 0.85

Calls 2

run_childFunction · 0.85
close_noerrFunction · 0.85

Tested by

no test coverage detected