1    	// Copyright (c) 2006, 2007 Julio M. Merino Vidal
2    	// Copyright (c) 2008 Ilya Sokolov, Boris Schaeling
3    	// Copyright (c) 2009 Boris Schaeling
4    	// Copyright (c) 2010 Felipe Tanus, Boris Schaeling
5    	// Copyright (c) 2011, 2012 Jeff Flinn, Boris Schaeling
6    	//
7    	// Distributed under the Boost Software License, Version 1.0. (See accompanying
8    	// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9    	
10   	#ifndef BOOST_PROCESS_DETAIL_POSIX_TERMINATE_HPP
11   	#define BOOST_PROCESS_DETAIL_POSIX_TERMINATE_HPP
12   	
13   	#include <boost/process/detail/config.hpp>
14   	#include <boost/process/detail/posix/child_handle.hpp>
15   	#include <system_error>
16   	#include <signal.h>
17   	#include <sys/wait.h>
18   	
19   	
20   	namespace boost { namespace process { namespace detail { namespace posix {
21   	
22   	inline void terminate(const child_handle &p, std::error_code &ec) noexcept
23   	{
(1) Event cond_false: Condition "kill(p.pid, 9) == -1", taking false branch.
24   	    if (::kill(p.pid, SIGKILL) == -1)
25   	        ec = boost::process::detail::get_last_error();
26   	    else
(2) Event else_branch: Reached else branch.
27   	        ec.clear();
28   	
29   	    int status;
(3) Event check_return: Calling "waitpid" without checking return value (as is done elsewhere 6 out of 7 times).
Also see events: [example_checked][example_checked][example_checked][example_assign][example_checked][example_assign][example_checked]
30   	    ::waitpid(p.pid, &status, 0); //just to clean it up
31   	}
32   	
33   	inline void terminate(const child_handle &p)
34   	{
35   	    std::error_code ec;
36   	    terminate(p, ec);
37   	    boost::process::detail::throw_error(ec, "kill(2) failed");
38   	}
39   	
40   	}}}}
41   	
42   	#endif
43