[PATCH 0/4] perf bench messaging: Kill child processes when exit abnormally in process mode

From: Yang Jihong
Date: Sat Sep 23 2023 - 05:32:14 EST


If perf bench messaging in process mode exits abnormally, the forked child
processes does not exit.

The test result is as follows:

# perf bench sched messaging -l 1000000 -g 1 &
[4] 553
# Running 'sched/messaging' benchmark:
# kill -15 533
# ps -ef | grep perf
root 425 371 0 09:11 pts/0 00:00:00 perf bench sched messaging -l 1000000 -g 1
root 426 425 17 09:11 pts/0 00:01:56 perf bench sched messaging -l 1000000 -g 1
root 427 425 17 09:11 pts/0 00:01:55 perf bench sched messaging -l 1000000 -g 1
root 428 425 17 09:11 pts/0 00:01:55 perf bench sched messaging -l 1000000 -g 1
root 429 425 17 09:11 pts/0 00:01:55 perf bench sched messaging -l 1000000 -g 1
root 430 425 17 09:11 pts/0 00:01:55 perf bench sched messaging -l 1000000 -g 1
root 431 425 17 09:11 pts/0 00:01:56 perf bench sched messaging -l 1000000 -g 1
root 432 425 17 09:11 pts/0 00:01:55 perf bench sched messaging -l 1000000 -g 1
root 433 425 17 09:11 pts/0 00:01:55 perf bench sched messaging -l 1000000 -g 1
root 434 425 17 09:11 pts/0 00:01:55 perf bench sched messaging -l 1000000 -g 1
root 435 425 17 09:11 pts/0 00:01:55 perf bench sched messaging -l 1000000 -g 1
root 436 425 17 09:11 pts/0 00:01:55 perf bench sched messaging -l 1000000 -g 1
root 437 425 17 09:11 pts/0 00:01:55 perf bench sched messaging -l 1000000 -g 1
root 438 425 17 09:11 pts/0 00:01:55 perf bench sched messaging -l 1000000 -g 1
root 439 425 17 09:11 pts/0 00:01:55 perf bench sched messaging -l 1000000 -g 1
root 440 425 17 09:11 pts/0 00:01:55 perf bench sched messaging -l 1000000 -g 1
root 441 425 17 09:11 pts/0 00:01:55 perf bench sched messaging -l 1000000 -g 1
root 442 425 17 09:11 pts/0 00:01:55 perf bench sched messaging -l 1000000 -g 1
root 443 425 17 09:11 pts/0 00:01:55 perf bench sched messaging -l 1000000 -g 1
root 444 425 17 09:11 pts/0 00:01:54 perf bench sched messaging -l 1000000 -g 1
root 445 425 17 09:11 pts/0 00:01:55 perf bench sched messaging -l 1000000 -g 1
root 446 425 16 09:11 pts/0 00:01:50 perf bench sched messaging -l 1000000 -g 1
root 447 425 16 09:11 pts/0 00:01:49 perf bench sched messaging -l 1000000 -g 1
root 448 425 16 09:11 pts/0 00:01:50 perf bench sched messaging -l 1000000 -g 1
root 449 425 16 09:11 pts/0 00:01:49 perf bench sched messaging -l 1000000 -g 1
root 450 425 16 09:11 pts/0 00:01:50 perf bench sched messaging -l 1000000 -g 1
root 451 425 16 09:11 pts/0 00:01:50 perf bench sched messaging -l 1000000 -g 1
root 452 425 16 09:11 pts/0 00:01:50 perf bench sched messaging -l 1000000 -g 1
root 453 425 16 09:11 pts/0 00:01:49 perf bench sched messaging -l 1000000 -g 1
root 454 425 16 09:11 pts/0 00:01:49 perf bench sched messaging -l 1000000 -g 1
<SNIP>

Capture signals SIGINT and SIGTERM to kill child processes in signal handler

Yang Jihong (4):
perf bench messaging: Fix coding style issues for sched-messaging
perf bench messaging: Factor out create_worker()
perf bench messaging: Store chlid process pid when creating worker for
process mode
perf bench messaging: Kill child processes when exit abnormally in
process mode

tools/perf/bench/sched-messaging.c | 102 ++++++++++++++++++-----------
1 file changed, 64 insertions(+), 38 deletions(-)

--
2.34.1