DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
Process.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/Process.h to include/okssystem/Process.hpp).
5
6/*
7 * Process.h
8 * OksSystem
9 *
10 * Created by Matthias Wiesmann on 18.01.05.
11 * Copyright 2005 CERN. All rights reserved.
12 *
13 */
14
15#ifndef OKSSYSTEM_PROCESS
16#define OKSSYSTEM_PROCESS
17
18#include <string>
19#include <sys/types.h>
20
21namespace OksSystem {
22
29
31{
32protected:
34 std::string m_process_name;
35 static const char* const SYS_EXITS_NAMES[];
36 static const char* const TEST_EXITS_NAMES[];
37 static const char* const OK_EXIT_NAME;
38 static const char* const SIGNAL_EXIT_NAME;
39 static const int TEST_BASE_VALUE;
40 static const int TEST_MAX_VALUE;
41 static const int TERMINATION_WAIT;
43public:
44 static const char* exit_text(int return_value);
45 static std::string exit_pretty(int return_value);
46 static const Process* instance() throw();
47 static void set_name(const std::string& name) throw();
48 Process();
49 Process(const Process& other);
50 Process(pid_t pid);
51 Process(pid_t pid, const std::string& name);
52 ~Process() throw();
53 operator pid_t() const throw();
54 int join(bool throw_non_zero = false) const;
55 void signal(int signal) const;
56 bool exists() const;
57 bool equals(const Process& other) const throw();
58 void terminate() const;
59 pid_t process_id() const throw();
60 std::string to_string() const throw();
61}; // Process
62
63} // OksSystem
64
65std::ostream&
66operator<<(std::ostream& stream, const OksSystem::Process& proc);
67bool
68operator==(const OksSystem::Process& a, const OksSystem::Process& b) throw();
69bool
70operator!=(const OksSystem::Process& a, const OksSystem::Process& b) throw();
71
72#endif
static const int TERMINATION_WAIT
wait time before deciding a termination signal did not work
Definition Process.hpp:41
static const Process * instance()
Definition Process.cpp:96
static const char *const OK_EXIT_NAME
string to describe 0 exit value
Definition Process.hpp:37
static const char * exit_text(int return_value)
the textual description of standard exit codes
Definition Process.cpp:60
int join(bool throw_non_zero=false) const
Waits for the process to terminate.
Definition Process.cpp:176
static const char *const SIGNAL_EXIT_NAME
string to describe signal exited value
Definition Process.hpp:38
bool equals(const Process &other) const
Comparison method.
Definition Process.cpp:232
static const int TEST_BASE_VALUE
first value for test manager exit codes
Definition Process.hpp:39
void signal(int signal) const
Sends a signal to the process.
Definition Process.cpp:204
pid_t m_process_id
process identifier
Definition Process.hpp:33
void terminate() const
Terminate the process.
Definition Process.cpp:243
static const char *const SYS_EXITS_NAMES[]
names for standard system exit values
Definition Process.hpp:34
static void set_name(const std::string &name)
Definition Process.cpp:108
static const int TEST_MAX_VALUE
last value for test manager exit codes
Definition Process.hpp:40
static std::string exit_pretty(int return_value)
Definition Process.cpp:78
bool exists() const
Does the process exist?
Definition Process.cpp:220
static const char *const TEST_EXITS_NAMES[]
names for testing exit values
Definition Process.hpp:44
pid_t process_id() const
the id of the process
Definition Process.cpp:289
static Process * s_instance
singleton instance
Definition Process.hpp:42
std::string m_process_name
process name - only to be used for display
Definition Process.hpp:34
Process()
Builds a process representing the current process.
Definition Process.cpp:118
std::string to_string() const
String conversion method.
Definition Process.cpp:275