Fix: tests: `pgrep -f` flags unrelated process as lttng-sessiond
authorJonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Fri, 22 May 2020 14:36:46 +0000 (10:36 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Tue, 11 Aug 2020 20:51:51 +0000 (16:51 -0400)
commit7cb78e2f73ef7bc0cfedef707f47f1c229bb4c43
treedb83f6311fe114daf5f67455876fab0ee05639f3
parentf5fb86c1254b785eee8caf87cb996d33eda0ede9
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 <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I479ebad27f4965ae16d4442a6fe58ff3157d76fa
tests/regression/tools/working-directory/test_relayd_working_directory
tests/stress/test_multi_sessions_per_uid_10app
tests/stress/test_multi_sessions_per_uid_5app_streaming
tests/stress/test_multi_sessions_per_uid_5app_streaming_kill_relayd
tests/utils/utils.sh
This page took 0.026375 seconds and 4 git commands to generate.