softwarecontainer  0.18.0-739e8d7 2017-05-04
executable.h
1 /*
2  *
3  * Copyright (C) 2016-2017 Pelagicore AB
4  *
5  * Permission to use, copy, modify, and/or distribute this software for
6  * any purpose with or without fee is hereby granted, provided that the
7  * above copyright notice and this permission notice appear in all copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
10  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
11  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR
12  * BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES
13  * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
14  * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
15  * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
16  * SOFTWARE.
17  *
18  * For further information see LICENSE
19  */
20 
21 #pragma once
22 
23 #include "softwarecontainer-common.h"
24 
25 namespace softwarecontainer {
26 
28 {
29 public:
30  // A function to be executed in the container
31  typedef std::function<int ()> ExecFunction;
32 
36  virtual bool execute(ExecFunction function,
37  pid_t *pid,
38  const EnvironmentVariables &variables = EnvironmentVariables(),
39  int stdin = -1,
40  int stdout = -1,
41  int stderr = 2) = 0;
42 
46  virtual bool execute(const std::string &commandLine,
47  pid_t *pid,
48  const EnvironmentVariables &variables = EnvironmentVariables(),
49  const std::string &workingDirectory = "/",
50  int stdin = -1,
51  int stdout = 1,
52  int stderr = 2) = 0;
53 };
54 
55 } // namespace softwarecontainer
virtual bool execute(ExecFunction function, pid_t *pid, const EnvironmentVariables &variables=EnvironmentVariables(), int stdin=-1, int stdout=-1, int stderr=2)=0
Executes a commandline.
Developers guide to adding a config item: