| 205 | } |
| 206 | |
| 207 | static 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 | |
| 234 | cleanup_pid: |
| 235 | batch->child_pid = 0; |
| 236 | close_noerr(inpipe[0]); |
| 237 | close_noerr(inpipe[1]); |
| 238 | close_outpipe: |
| 239 | close_noerr(outpipe[0]); |
| 240 | close_noerr(outpipe[1]); |
| 241 | return false; |
| 242 | } |
| 243 | |
| 244 | static bool check_with_child(struct ptr_valid_batch *batch, |
| 245 | const void *p, size_t size, bool is_write) |
no test coverage detected