terminate.hpp
Go to the documentation of this file.
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 #pragma once
11 
12 #include <signal.h>
13 
14 #include <boost/process/config.hpp>
15 #include <boost/system/error_code.hpp>
16 
17 namespace boost::process::posix
18 {
19 
20  template <class Process>
21  void
22  terminate(const Process& p)
23  {
24  if (::kill(p.pid, SIGKILL) == -1)
25  {
26  BOOST_PROCESS_THROW_LAST_SYSTEM_ERROR("kill(2) failed");
27  }
28  }
29 
30  template <class Process>
31  void
32  terminate(const Process& p, boost::system::error_code& ec)
33  {
34  if (::kill(p.pid, SIGKILL) == -1)
35  {
36  BOOST_PROCESS_RETURN_LAST_SYSTEM_ERROR(ec);
37  }
38  else
39  {
40  ec.clear();
41  }
42  }
43 
44 } // namespace boost::process::posix
config.hpp
boost::process::posix::terminate
void terminate(const Process &p)
Definition: terminate.hpp:22
boost::process::posix
Definition: child.hpp:14