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/42ab3f64 Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/42ab3f64 Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/42ab3f64 Branch: refs/heads/1.5.x Commit: 42ab3f6417d07fce3fcfb3d713cdcb7d04d64039 Parents: e524ac3 Author: Greg Mann <[email protected]> Authored: Fri Feb 23 16:41:44 2018 -0800 Committer: Gilbert Song <[email protected]> Committed: Wed Mar 7 01:08:12 2018 -0800 ---------------------------------------------------------------------- src/docker/docker.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/42ab3f64/src/docker/docker.cpp ---------------------------------------------------------------------- diff --git a/src/docker/docker.cpp b/src/docker/docker.cpp index c2feebe..3f20900 100644 --- 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); + } }
