Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
Process.h
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2026 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
4// See the top-level COPYRIGHT file for details.
5// SPDX-License-Identifier: Apache-2.0
6//-----------------------------------------------------------------------------
7/*---------------------------------------------------------------------------*/
8/* Process.h (C) 2000-2025 */
9/* */
10/* Process management. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCCORE_COMMON_INTERNAL_PROCESS_H
13#define ARCCORE_COMMON_INTERNAL_PROCESS_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arccore/base/String.h"
18
19#include "arccore/common/Array.h"
20
21/*---------------------------------------------------------------------------*/
22/*---------------------------------------------------------------------------*/
23
24namespace Arcane
25{
26
27/*---------------------------------------------------------------------------*/
28/*---------------------------------------------------------------------------*/
29
30class ARCCORE_COMMON_EXPORT ProcessExecArgs
31{
32 friend class Process;
33
34 public:
35
36 enum class ExecStatus
37 {
38 // The child process terminated correctly (but may have errors)
39 OK,
41 CanNotFork,
43 CanNotCreatePipe,
44 // The child process did not terminate correctly (void waitpid())
45 AbnormalExit
46 };
47
48 public:
49
51 String command() const { return m_command; }
52 void setCommand(const String& v) { m_command = v; }
53
55 ConstArrayView<String> arguments() const { return m_arguments; }
56 void addArguments(const String& v) { m_arguments.add(v); }
57 void setArguments(const Array<String>& v) { m_arguments = v; }
58
60 ConstArrayView<Byte> inputBytes() const { return m_input_bytes; }
61 void setInputBytes(ConstArrayView<Byte> s) { m_input_bytes = s; }
62
64 ConstArrayView<Byte> outputBytes() const { return m_output_bytes; }
66 int exitCode() const { return m_exit_code; }
67
68 private:
69
70 String m_command;
71 UniqueArray<String> m_arguments;
72 UniqueArray<Byte> m_input_bytes;
73 UniqueArray<Byte> m_output_bytes;
74 int m_exit_code = 0;
75};
76
77/*---------------------------------------------------------------------------*/
78/*---------------------------------------------------------------------------*/
79
83class ARCCORE_COMMON_EXPORT Process
84{
85 public:
86
89};
90
91/*---------------------------------------------------------------------------*/
92/*---------------------------------------------------------------------------*/
93
94} // namespace Arcane
95
96/*---------------------------------------------------------------------------*/
97/*---------------------------------------------------------------------------*/
98
99#endif
Constant view of an array of type T.
ConstArrayView< Byte > outputBytes() const
Contains the result of the process's standard output (STDOUT).
Definition Process.h:64
ConstArrayView< String > arguments() const
List of arguments.
Definition Process.h:55
String command() const
Command to execute. Must correspond to an executable.
Definition Process.h:51
int exitCode() const
Return code of the executed process.
Definition Process.h:66
ConstArrayView< Byte > inputBytes() const
String to send to the process's standard input (STDIN).
Definition Process.h:60
Class allowing the execution of an external process.
Definition Process.h:84
static ProcessExecArgs::ExecStatus execute(ProcessExecArgs &args)
Executes a process whose information is contained in args.
Definition Process.cc:40
1D data vector with value semantics (STL style).
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --