From: Jonathan Rajotte Date: Fri, 22 May 2020 14:36:46 +0000 (-0400) Subject: Fix: tests: `pgrep -f` flags unrelated process as lttng-sessiond X-Git-Tag: v2.13.0-rc1~505 X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=commitdiff_plain;h=7cb78e2f73ef7bc0cfedef707f47f1c229bb4c43;hp=7cb78e2f73ef7bc0cfedef707f47f1c229bb4c43 Fix: tests: `pgrep -f` flags unrelated process as lttng-sessiond Observed issue ============== lttng-sessiond is not started by start_lttng_sessiond_opt and a vim process is killed on stop_lttng_sessiond_opt. Cause ===== We uses "pgrep -f" with the interested pattern to gather the pids that should be the lttng processes we are interested in. `pgrep -f` yields false positives since it matches against the complete cmdline including parent directory of the command and all arguments. For example, the following will currently match for the sessiond pattern: vim src/bin/lttng-sessiond/notification-thread-internal.h This prevents the launch of sessiond by start_lttng_sessiond_opt and end up killing the vim process on stop_lttng_sessiond_opt. Solution ======== To alleviate this, we propose a two stage lookup. The first stage uses "pgrep -f" yielding potential candidates. The second stage performs grep on the basename of the first field of the /proc/[pid]/cmdline for each pid candidates. The first field of /proc/[pid]/cmdline corresponds to the actual command. We use the basename to ensure that we do not match on the path to the executable. Known drawbacks ========= None References ========== https://review.lttng.org/c/lttng-tools/+/3043 Signed-off-by: Jonathan Rajotte Signed-off-by: Jérémie Galarneau Change-Id: I479ebad27f4965ae16d4442a6fe58ff3157d76fa ---