SystemCall.h
1//-*-C++-*-
2/***************************************************************************
3 *
4 * Copyright (C) 2012 - 2023 by Willem van Straten
5 * Licensed under the Academic Free License version 2.1
6 *
7 ***************************************************************************/
8
9/* Util/genutil/SystemCall.h */
10
11#ifndef __Util_genutil_SystemCall_h
12#define __Util_genutil_SystemCall_h
13
14#include <string>
15
18{
19 unsigned retries {3};
20 bool throw_exception {true};
21 int return_value {0};
22
23 public:
24
26 void set_retries (unsigned n) { retries = n; }
27
29 void set_throw (bool flag) { throw_exception = flag; }
30
32 int get_return_value () const { return return_value; }
33
35
36 void run (const std::string&);
37
38};
39
40#endif // !defined(__Util_genutil_SystemCall_h)
41
Executes a system call with multiple retries.
Definition SystemCall.h:18
void run(const std::string &)
Run the given command.
Definition SystemCall.C:19
void set_retries(unsigned n)
Set the number of retries.
Definition SystemCall.h:26
int get_return_value() const
Get the return value (exit status) of the last executed command.
Definition SystemCall.h:32
void set_throw(bool flag)
Throw an exception if the command returns a non-zero exit status.
Definition SystemCall.h:29

Generated using doxygen 1.14.0