bool job_write(int id, char *data, uint32_t len) { Job *job = find_job(id); if (job == NULL || job->stopped) { free(data); return false; } if (!wstream_write(job->in, data, len, true)) { job_stop(job->id); return false; } return true; }
/// Releases job control resources and terminates running jobs void job_teardown(void) { // Stop all jobs for (int i = 0; i < MAX_RUNNING_JOBS; i++) { Job *job; if ((job = table[i]) != NULL) { uv_kill(job->pid, SIGTERM); job->term_sent = true; job_stop(job); } } // Wait until all jobs are closed event_poll_until(-1, !stop_requests); uv_signal_stop(&schld); uv_close((uv_handle_t *)&schld, NULL); // Close the timer uv_close((uv_handle_t *)&job_stop_timer, NULL); }