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
34 class Executable : public File {
35
36public:
37 typedef std::vector<std::string> param_collection ;
38 typedef std::map<std::string, std::string> env_collection ;
39protected:
40 void exec(char** argv) const ;
41 void exec(char** const argv, char** const env) const ;
42 static const char* const SHELL_COMMAND ;
43 static const char* const SHELL_COMMAND_PARAM ;
44 static void copy_fd(int fd, std::ostream &target) ;
45public:
46 static std::string okssystem(const std::string &command);
47
48 Executable(const OksSystem::File &file) ;
49 Executable(const char* filename) ;
50 Executable(const std::string &filename) ;
51 ~Executable() ;
52
53 void exec() const ;
54 void exec(const param_collection &params) const ;
55 std::string pipe_in(const param_collection &params) const ;
56 std::string pipe_in(const param_collection &params, const env_collection &envs) const ;
57 Process pipe_out(const param_collection &params, const File &input_file, const File &output_file, const File &error_file, mode_t perm) const ;
58 Process pipe_out(const param_collection &params, const env_collection &envs, const File &input_file, const File &output_file, const File &error_file, mode_t perm) const ;
59 void exec(const param_collection &params, const env_collection &envs) const ;
60 Process start(const param_collection &params) const ;
61 Process start_and_forget(const param_collection &params) const ;
62 Process start(const param_collection &params, const env_collection &envs) const ;
63
64 std::string to_string(const param_collection &params) const ;
65
66 } ; // Executable
67
68} // OksSystem
69
70#endif
71
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
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:37
File(const std::string &name)
Definition File.cpp:301
Wrapper for process manipulation.
Definition Process.hpp:30