path: root/glustolibs-gluster/glustolibs/gluster
diff options
authorkshithijiyer <>2020-04-28 12:58:07 +0530
committerkshithijiyer <>2020-04-28 12:58:07 +0530
commit297637c78741c8348eb053ddd0b3bc12d068a9e2 (patch)
tree99e7b27b10618ad7914c1f3b0a7a6bea3abdfbb8 /glustolibs-gluster/glustolibs/gluster
parent83afdf79df7ef3bd5c4557fdacc58e4513d76438 (diff)
[Libfix] Fix check_brick_pid_matches_glusterfsd_pid() to use pgrep
Problem: On latest platforms pidof command is returning multiple pids as shown below: 27190 27078 26854 This is becasue it was returning glusterd,glusterfsd and glusterfs processes as well. The problem is that /usr/sbin/glusterd is a link to glusterfsd. 'pidof' has a new feature that pidof searches for the pattern in /proc/PID/cmdline, /proc/PID/stat and finally /proc/PID/exe. Hence pidof matches realpath of /proc/<pid_of_glusterd>/exe as /usr/sbin/glusterfsd and results in glusterd, glusterfs and glusterfsd pids being returned in output. Fix: Use pgrep instead of pidof to get glusterfsd pids. And change the split logic accordingly. Change-Id: I729e05c3f4cacf7bf826592da965a94a49bb6f33 Signed-off-by: kshithijiyer <>
Diffstat (limited to 'glustolibs-gluster/glustolibs/gluster')
1 files changed, 2 insertions, 2 deletions
diff --git a/glustolibs-gluster/glustolibs/gluster/ b/glustolibs-gluster/glustolibs/gluster/
index 3defdba8a..b56434741 100755
--- a/glustolibs-gluster/glustolibs/gluster/
+++ b/glustolibs-gluster/glustolibs/gluster/
@@ -119,7 +119,7 @@ def check_brick_pid_matches_glusterfsd_pid(mnode, volname):
"of brick path %s", brick_node, brick_path)
_rc = False
- cmd = "pidof glusterfsd"
+ cmd = "pgrep -x glusterfsd"
ret, pid, _ =, cmd)
if ret != 0:
g.log.error("Failed to run the command %s on "
@@ -127,7 +127,7 @@ def check_brick_pid_matches_glusterfsd_pid(mnode, volname):
_rc = False
- glusterfsd_pid = pid.split()
+ glusterfsd_pid = pid.split('\n')[:-1]
if brick_pid not in glusterfsd_pid:
g.log.error("Brick pid %s doesn't match glusterfsd "