The solution with using pkill was not ideal as pkill would match the process it was meant to kill and the shell running pkill as well. This could lead to a situation where the shell would be killed first and the signal would not be delivered to the intended target process.
Related issues
Bug #24927: Ansible processes might get killed when logrotate runs for smart_proxy_dynflow_core
Fixes #24927 - Fix sending signal after logrotate
The solution with using pkill was not ideal as pkill
would match the process it was meant to kill and the
shell running pkill as well. This could lead to
a situation where the shell would be killed first
and the signal would not be delivered to the intended
target process.