The break value '-b' is not working properly: - Every thread may hit the break value. This is expected for thread number > 0 because thread number 0 sleeps every 16 iterations to give the system time to breath. This delay may wrongly trigger as the break value. - If a thread hits the break value then it returns signaling "shutdown". The main thread will then SIGTERM to each of the remaining threads. This is a nop because this signal is blocked. Send SIGUSR1 instead which is waited for. While doing all of this, report the actual `max' value. Signed-off-by: Sebastian Andrzej Siewior <bigeasy@xxxxxxxxxxxxx> --- src/signaltest/signaltest.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/signaltest/signaltest.c b/src/signaltest/signaltest.c index 84eb8827faa5e..dacaa63673c48 100644 --- a/src/signaltest/signaltest.c +++ b/src/signaltest/signaltest.c @@ -58,6 +58,7 @@ struct thread_stat { pthread_t tothread; int threadstarted; int tid; + int interrupted; }; static int shutdown; @@ -123,13 +124,16 @@ void *signalthread(void *param) diff = calcdiff(after, before); before = now; + if (diff < stat->min) stat->min = diff; if (diff > stat->max) stat->max = diff; stat->avg += (double) diff; - if (!stopped && tracelimit && (diff > tracelimit)) { + if (!stopped && tracelimit && !par->id && (diff > tracelimit)) { + stat->act = diff; + stat->interrupted = 1; stopped++; shutdown++; } @@ -376,11 +380,12 @@ int main(int argc, char **argv) quiet = 2; for (i = 0; i < num_threads; i++) { if (stat[i].threadstarted > 0) - pthread_kill(stat[i].thread, SIGTERM); + pthread_kill(stat[i].thread, SIGUSR1); + if (stat[i].interrupted) + printf("Thread %d exceeded trace limit.\n", i); if (stat[i].threadstarted) { pthread_join(stat[i].thread, NULL); - if (quiet && (i == 0)) - print_stat(&par[i], i, 0); + print_stat(&par[i], i, 0); } if (stat[i].values) free(stat[i].values); -- 2.29.2