DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
Executable.hpp
Go to the documentation of this file.
1// DUNE DAQ modification notice:
2// This file has been modified from the original ATLAS system source for the DUNE DAQ project.
3// Fork baseline commit: system-00-00-20 (2020-09-25).
4// Renamed since fork: yes (from system/Executable.h to include/okssystem/Executable.hpp).
5
6/*
7 * Executable.h
8 * OksSystem
9 *
10 * Created by Matthias Wiesmann on 06.01.05.
11 * Copyright 2005 CERN. All rights reserved.
12 *
13 */
14
15#ifndef OKSSYSTEM_EXECUTABLE
16#define OKSSYSTEM_EXECUTABLE
17
18#include <map>
19#include <vector>
20
21#include "okssystem/File.hpp"
22#include "okssystem/Process.hpp"
23
24namespace OksSystem {
25
33
34class Executable : public File
35{
36
37public:
38 typedef std::vector<std::string> param_collection;
39 typedef std::map<std::string, std::string> env_collection;
40
41protected:
42 void exec(char** argv) const;
43 void exec(char** const argv, char** const env)
44 const;
45 static const char* const SHELL_COMMAND;
46 static const char* const SHELL_COMMAND_PARAM;
47 static void copy_fd(int fd,
48 std::ostream& target);
49public:
50 static std::string okssystem(const std::string& command);
51
52 Executable(const OksSystem::File& file);
53 Executable(const char* filename);
54 Executable(const std::string& filename);
56
57 void exec() const;
58 void exec(const param_collection& params) const;
59 std::string pipe_in(const param_collection& params) const;
60 std::string pipe_in(const param_collection& params, const env_collection& envs) const;
61 Process pipe_out(const param_collection& params,
62 const File& input_file,
63 const File& output_file,
64 const File& error_file,
65 mode_t perm) const;
66 Process pipe_out(const param_collection& params,
67 const env_collection& envs,
68 const File& input_file,
69 const File& output_file,
70 const File& error_file,
71 mode_t perm) const;
72 void exec(const param_collection& params, const env_collection& envs) const;
73 Process start(const param_collection& params) const;
75 const;
76 Process start(const param_collection& params,
77 const env_collection& envs) const;
78
79 std::string to_string(const param_collection& params)
80 const;
81
82}; // Executable
83
84} // OksSystem
85
86#endif
Process start_and_forget(const param_collection &params) const
start the executable in another process; do not wait for termination of child
Executable(const OksSystem::File &file)
std::string pipe_in(const param_collection &params) const
run the executable and pipe results back
Process pipe_out(const param_collection &params, const File &input_file, const File &output_file, const File &error_file, mode_t perm) const
static const char *const SHELL_COMMAND
command to execute in a shell
std::vector< std::string > param_collection
std::map< std::string, std::string > env_collection
Process start(const param_collection &params) const
start the executable in another process
void exec(char **argv) const
does the actual exec
static std::string okssystem(const std::string &command)
execute a command in a shell
static const char *const SHELL_COMMAND_PARAM
parameter to execute in a shell
std::string to_string(const param_collection &params) const
converts executable name and a parameter sequence into a string
void exec() const
run the executable
static void copy_fd(int fd, std::ostream &target)
copies the content of a file descriptor into a STL stream
Wrapper for file operations.
Definition File.hpp:38
File(const std::string &name)
Definition File.cpp:327
Wrapper for process manipulation.
Definition Process.hpp:31