void fork_deferred_worker(void) { u_int idx; blocking_child * c; REQUIRE(droproot && root_dropped); for (idx = 0; idx < blocking_children_alloc; idx++) { c = blocking_children[idx]; if (NULL == c) continue; if (-1 != c->req_write_pipe && 0 == c->pid) fork_blocking_child(c); } }
int send_blocking_req_internal( blocking_child * c, blocking_pipe_header * hdr, void * data ) { int octets; int rc; DEBUG_REQUIRE(hdr != NULL); DEBUG_REQUIRE(data != NULL); DEBUG_REQUIRE(BLOCKING_REQ_MAGIC == hdr->magic_sig); if (-1 == c->req_write_pipe) { fork_blocking_child(c); DEBUG_INSIST(-1 != c->req_write_pipe); } octets = sizeof(*hdr); rc = write(c->req_write_pipe, hdr, octets); if (rc == octets) { octets = hdr->octets - sizeof(*hdr); rc = write(c->req_write_pipe, data, octets); if (rc == octets) return 0; } if (rc < 0) msyslog(LOG_ERR, "send_blocking_req_internal: pipe write: %m"); else msyslog(LOG_ERR, "send_blocking_req_internal: short write %d of %d", rc, octets); /* Fatal error. Clean up the child process. */ req_child_exit(c); exit(1); /* otherwise would be return -1 */ }