| 200 | } |
| 201 | |
| 202 | static 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 | |
| 229 | cleanup_pid: |
| 230 | batch->child_pid = 0; |
| 231 | close_noerr(inpipe[0]); |
| 232 | close_noerr(inpipe[1]); |
| 233 | close_outpipe: |
| 234 | close_noerr(outpipe[0]); |
| 235 | close_noerr(outpipe[1]); |
| 236 | return false; |
| 237 | } |
| 238 | |
| 239 | static bool check_with_child(struct ptr_valid_batch *batch, |
| 240 | const void *p, size_t size, bool is_write) |
no test coverage detected