From: Jonathan Rajotte Date: Wed, 17 Feb 2021 14:19:50 +0000 (-0500) Subject: Fix: tests: handling of subprocesses on bail out X-Git-Tag: v2.13.0-rc1~115 X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=commitdiff_plain;h=a0f8e3109abc7d77c9cb3149193651e31360bca0;hp=a0f8e3109abc7d77c9cb3149193651e31360bca0 Fix: tests: handling of subprocesses on bail out Observed issue ============== Background processes of the test_notification_ust tests are present on CI worker after the jobs is finished. Cause ===== The usage of BAIL_OUT during the notap version of stop lttng-sessiond would end up preventing the normal cleanup of background processes since we exit directly when issuing the bail out. Solution ======== Introduce LTTNG_BAIL_OUT. LTTNG_BAIL_OUT ensure that we call the cleanup path that is normally used when testing is interrupted. Add the flag `is_cleanup` to all relevant `*stop_opts` functions. And introduce the `*_cleanup` functions for relayd, sessiond, consumerd. While at it, a small rework on how we kill the subprocesses of the non-iteractive shell was done. This is useful because when using the test runner the group id of the running process performing the kill is not valid and result in simply not propagating the SIGTERM signal. We now use "set -m" to enable monitor mode ensuring that all background jobs is its own process group id, facilitating the usage of kill with negative value to ensure that each background jobs subprocesses receives the SIGTERM signal. Known drawbacks ========= We introduce a new lttng specific bail out directive instead of using the BAIL_OUT from tap.sh We could override the BAIL_OUT function based on [1]. [1] https://mharrison.org/post/bashfunctionoverride/ References ========== https://linux.die.net/man/1/bash#:~:text=Monitor%20mode Signed-off-by: Jonathan Rajotte Signed-off-by: Jérémie Galarneau Change-Id: I42ce8659df3e1d9078cc1a46a11a33a2df9a145e ---