瀏覽代碼

HADOOP-14855. Hadoop scripts may errantly believe a daemon is still running, preventing it from starting. Contributed by Robert Kanter.

Miklos Szegedi 7 年之前
父節點
當前提交
e52539b46f
共有 1 個文件被更改,包括 7 次插入2 次删除
  1. 7 2
      hadoop-common-project/hadoop-common/src/main/bin/hadoop-functions.sh

+ 7 - 2
hadoop-common-project/hadoop-common/src/main/bin/hadoop-functions.sh

@@ -1725,11 +1725,16 @@ function hadoop_status_daemon
   shift
   shift
 
 
   local pid
   local pid
+  local pspid
 
 
   if [[ -f "${pidfile}" ]]; then
   if [[ -f "${pidfile}" ]]; then
     pid=$(cat "${pidfile}")
     pid=$(cat "${pidfile}")
-    if ps -p "${pid}" > /dev/null 2>&1; then
-      return 0
+    if pspid=$(ps -o args= -p"${pid}" 2>/dev/null); then
+      # this is to check that the running process we found is actually the same
+      # daemon that we're interested in
+      if [[ ${pspid} =~ -Dproc_${daemonname} ]]; then
+        return 0
+      fi
     fi
     fi
     return 1
     return 1
   fi
   fi