blob: 1145b30fcfeeb2e7a132ef868c729c17d383b4be [file] [log] [blame]
Elly Jonesa44d22d2012-01-05 18:05:56 -05001// Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
Elly Jones0c016cc2011-12-19 16:19:22 -05002// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
Alex Vakulenko262be3f2014-07-30 15:25:50 -07005#ifndef DEBUGD_SRC_SUBPROCESS_TOOL_H_
6#define DEBUGD_SRC_SUBPROCESS_TOOL_H_
Elly Jones0c016cc2011-12-19 16:19:22 -05007
8#include <map>
Ben Chan23142892017-02-15 12:34:13 -08009#include <memory>
Elly Jones0c016cc2011-12-19 16:19:22 -050010#include <string>
11
Ben Chan657bed82014-09-02 20:40:51 -070012#include <base/macros.h>
Eric Carusocc7106c2017-04-27 14:22:42 -070013#include <brillo/errors/error.h>
Elly Jones0c016cc2011-12-19 16:19:22 -050014
Ben Chan23142892017-02-15 12:34:13 -080015#include "debugd/src/process_with_id.h"
Elly Jones0c016cc2011-12-19 16:19:22 -050016
Ben Chan23142892017-02-15 12:34:13 -080017namespace debugd {
Elly Jones0c016cc2011-12-19 16:19:22 -050018
19class SubprocessTool {
20 public:
Ben Chan78f89532014-08-29 09:35:09 -070021 SubprocessTool() = default;
22 virtual ~SubprocessTool() = default;
Elly Jones0c016cc2011-12-19 16:19:22 -050023
Ben Chan0d840a72018-09-27 00:24:48 -070024 virtual ProcessWithId* CreateProcess(bool sandboxed,
25 bool allow_root_mount_ns);
Jorge Lucangeli Obes623f8ca2014-09-18 10:50:06 -070026
Mike Frysingerf9da3d32017-09-19 23:41:27 -040027 // TODO(vapier): Rework sandboxing so we can re-internalize this function.
28 bool RecordProcess(std::unique_ptr<ProcessWithId> process);
29
Eric Carusocc7106c2017-04-27 14:22:42 -070030 virtual bool Stop(const std::string& handle, brillo::ErrorPtr* error);
Ben Chana0011d82014-05-13 00:19:29 -070031
Elly Jones0c016cc2011-12-19 16:19:22 -050032 private:
Ben Chan23142892017-02-15 12:34:13 -080033 std::map<std::string, std::unique_ptr<ProcessWithId>> processes_;
Ben Chana0011d82014-05-13 00:19:29 -070034
Elly Jones0c016cc2011-12-19 16:19:22 -050035 DISALLOW_COPY_AND_ASSIGN(SubprocessTool);
36};
37
Ben Chana0011d82014-05-13 00:19:29 -070038} // namespace debugd
Elly Jones0c016cc2011-12-19 16:19:22 -050039
Alex Vakulenko262be3f2014-07-30 15:25:50 -070040#endif // DEBUGD_SRC_SUBPROCESS_TOOL_H_