From 5d538da63a92fd45c24765fa4735d2ba2e679012 Mon Sep 17 00:00:00 2001 From: Andrew Wood Date: Wed, 29 Oct 2025 21:30:43 +0000 Subject: [PATCH] Add the stoppage time to the each of currently watched fds' counters (#169). --- src/pv/signal.c | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/src/pv/signal.c b/src/pv/signal.c index 1fe3f31..f9e73b9 100644 --- a/src/pv/signal.c +++ b/src/pv/signal.c @@ -174,7 +174,35 @@ static void pv_sig_cont( /*@unused@ */ __attribute__((unused)) pv_elapsedtime_add(&(pv_sig_state->signal.total_stoppage_time), &(pv_sig_state->signal.total_stoppage_time), &time_spent_stopped); - /* TODO: also update every watched fd's stopped-time count in watchfd mode (#169) */ + /* In watchfd mode, update the stoppage time of all watched fds. */ + if (pv_sig_state->watchfd.count > 0 && NULL != pv_sig_state->watchfd.watching) { + unsigned int watch_idx; + + for (watch_idx = 0; watch_idx < pv_sig_state->watchfd.count; watch_idx++) { + int info_idx; + + if (pv_sig_state->watchfd.watching[watch_idx].finished) + continue; + + if (NULL == pv_sig_state->watchfd.watching[watch_idx].info_array) + continue; + + for (info_idx = 0; info_idx < pv_sig_state->watchfd.watching[watch_idx].array_length; + info_idx++) { + pvwatchfd_t info_item = + &(pv_sig_state->watchfd.watching[watch_idx].info_array[info_idx]); + + if (info_item->unused) + continue; + + if (!info_item->displayable) + continue; + + pv_elapsedtime_add(&(info_item->total_stoppage_time), + &(info_item->total_stoppage_time), &time_spent_stopped); + } + } + } /* reset the SIGTSTP receipt time */ pv_elapsedtime_zero(&(pv_sig_state->signal.when_tstp_arrived));