Skip to content

Commit 71c3c40

Browse files
committed
'sudo pkill -f' should not match the sudo process
pkill already takes care that it does not kill itself, however the same problem may happen with 'sudo pkill -f' killing sudo. Use one of the usual regex tricks to avoid that. Change-Id: Ic6a94f516cbc509a2d77699494aa7bcaecf96ebc Closes-Bug: #1999395
1 parent 864f4d1 commit 71c3c40

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

lib/neutron

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -689,7 +689,9 @@ function stop_other {
689689
fi
690690

691691
if [[ "$Q_USE_ROOTWRAP_DAEMON" == "True" ]]; then
692-
sudo pkill -9 -f $NEUTRON_ROOTWRAP-daemon || :
692+
# pkill takes care not to kill itself, but it may kill its parent
693+
# sudo unless we use the "ps | grep [f]oo" trick
694+
sudo pkill -9 -f "$NEUTRON_ROOTWRAP-[d]aemon" || :
693695
fi
694696
}
695697

lib/neutron_plugins/ovn_agent

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -769,7 +769,9 @@ function _stop_process {
769769

770770
function stop_ovn {
771771
if is_service_enabled q-ovn-metadata-agent neutron-ovn-metadata-agent; then
772-
sudo pkill -9 -f haproxy || :
772+
# pkill takes care not to kill itself, but it may kill its parent
773+
# sudo unless we use the "ps | grep [f]oo" trick
774+
sudo pkill -9 -f "[h]aproxy" || :
773775
_stop_process "devstack@q-ovn-metadata-agent.service"
774776
fi
775777
if is_service_enabled ovn-controller-vtep ; then

0 commit comments

Comments
 (0)