Fio will no longer stall waiting for dead children.
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
static void reap_threads(int *nr_running, int *t_rate, int *m_rate)
{
struct thread_data *td;
static void reap_threads(int *nr_running, int *t_rate, int *m_rate)
{
struct thread_data *td;
- int i, cputhreads, pending;
+ int i, cputhreads, pending, status, ret;
/*
* reap exited threads (TD_EXITED -> TD_REAPED)
/*
* reap exited threads (TD_EXITED -> TD_REAPED)
if (td->io_ops && td->io_ops->flags & FIO_CPUIO)
cputhreads++;
if (td->io_ops && td->io_ops->flags & FIO_CPUIO)
cputhreads++;
+ if (td->runstate < TD_EXITED) {
+ /*
+ * check if someone quit or got killed in an unusual way
+ */
+ ret = waitpid(td->pid, &status, WNOHANG);
+ if (ret < 0)
+ perror("waitpid");
+ else if ((ret == td->pid) && WIFSIGNALED(status)) {
+ int sig = WTERMSIG(status);
+
+ log_err("fio: pid=%d, got signal=%d\n", td->pid, sig);
+ td_set_runstate(td, TD_REAPED);
+ goto reaped;
+ }
+ }
+
if (td->runstate != TD_EXITED) {
if (td->runstate < TD_RUNNING)
pending++;
if (td->runstate != TD_EXITED) {
if (td->runstate < TD_RUNNING)
pending++;
- waitpid(td->pid, &status, 0);
+ ret = waitpid(td->pid, &status, 0);
+ if (ret < 0)
+ perror("waitpid");
if (WIFEXITED(status) && WEXITSTATUS(status)) {
if (!exit_value)
exit_value++;
}
}
if (WIFEXITED(status) && WEXITSTATUS(status)) {
if (!exit_value)
exit_value++;
}
}
(*nr_running)--;
(*m_rate) -= td->ratemin;
(*t_rate) -= td->rate;
(*nr_running)--;
(*m_rate) -= td->ratemin;
(*t_rate) -= td->rate;