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

Function create_child

ccan/ccan/ptr_valid/ptr_valid.c:207–242  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 1

check_with_childFunction · 0.85

Calls 2

close_noerrFunction · 0.85
run_childFunction · 0.70

Tested by

no test coverage detected