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/e26355f9 Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/e26355f9 Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/e26355f9 Branch: refs/heads/1.4.x Commit: e26355f91383e37e6e7fe6e58816692db7116303 Parents: ecd0dd8 Author: Greg Mann <[email protected]> Authored: Fri Feb 23 16:41:44 2018 -0800 Committer: Gilbert Song <[email protected]> Committed: Fri Mar 2 16:55:50 2018 -0800 ---------------------------------------------------------------------- src/docker/docker.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/e26355f9/src/docker/docker.cpp ---------------------------------------------------------------------- diff --git a/src/docker/docker.cpp b/src/docker/docker.cpp index 192e170..f0dbd8d 100755 --- a/src/docker/docker.cpp +++ b/src/docker/docker.cpp @@ -148,8 +148,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); + } }
