Prevented Docker library from terminating incorrect processes.

Previously, the Docker library might call `os::killtree()` on a
PID after the associated subprocess had already terminated, which
could lead to an unknown process being incorrectly killed.

Review: https://reviews.apache.org/r/65786/


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/7eb4f1bc
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/7eb4f1bc
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/7eb4f1bc

Branch: refs/heads/1.3.x
Commit: 7eb4f1bce12ef17bdef1463cd033dfb5026332c2
Parents: b5b0ad1
Author: Greg Mann <g...@mesosphere.io>
Authored: Fri Feb 23 16:41:44 2018 -0800
Committer: Gilbert Song <songzihao1...@gmail.com>
Committed: Fri Mar 2 16:57:31 2018 -0800

----------------------------------------------------------------------
 src/docker/docker.cpp | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/7eb4f1bc/src/docker/docker.cpp
----------------------------------------------------------------------
diff --git a/src/docker/docker.cpp b/src/docker/docker.cpp
index 9be1431..3f99293 100755
--- a/src/docker/docker.cpp
+++ b/src/docker/docker.cpp
@@ -146,8 +146,10 @@ Try<Owned<Docker>> Docker::create(
 
 void commandDiscarded(const Subprocess& s, const string& cmd)
 {
-  VLOG(1) << "'" << cmd << "' is being discarded";
-  os::killtree(s.pid(), SIGKILL);
+  if (s.status().isPending()) {
+    VLOG(1) << "'" << cmd << "' is being discarded";
+    os::killtree(s.pid(), SIGKILL);
+  }
 }
 
 

Reply via email to