blob: ddbe7cbf05de82d2ac565b9c1ee2df57bf51e909 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
// slang-process.h
#ifndef SLANG_PROCESS_H
#define SLANG_PROCESS_H
#include "slang-string.h"
#include "slang-list.h"
#include "slang-stream.h"
#include "slang-io.h"
#include "slang-string-escape-util.h"
#include "slang-command-line.h"
namespace Slang {
class Process : public RefObject
{
public:
enum class StreamType
{
ErrorOut,
StdOut,
StdIn,
CountOf,
};
typedef uint32_t Flags;
struct Flag
{
enum Enum : Flags
{
AttachDebugger = 0x01,
};
};
/// Get the stream for the type
Stream* getStream(StreamType type) const { return m_streams[Index(type)]; }
int32_t getReturnValue() const { return m_returnValue; }
/// True if the process has terminated
virtual bool isTerminated() = 0;
/// Blocks until the process has completed
virtual void waitForTermination() = 0;
/// The quoting style used for the command line on this target. Currently just uses Space,
/// but in future may take into account platform sec
static StringEscapeHandler* getEscapeHandler();
/// Get the suffix used on this platform
static UnownedStringSlice getExecutableSuffix();
/// Create a process using the executable/args defined from the commandLine
static SlangResult create(const CommandLine& commandLine, Process::Flags flags, RefPtr<Process>& outProcess);
/// Sleep the current thread for time specified in milliseconds. 0 indicates to OS ok to yield this thread.
static void sleepCurrentThread(Index timeInMs);
/// Get a standard stream
static SlangResult getStdStream(StreamType type, RefPtr<Stream>& out);
static uint64_t getClockFrequency();
static uint64_t getClockTick();
protected:
int32_t m_returnValue = 0; ///< Value returned if process terminated
RefPtr<Stream> m_streams[Index(StreamType::CountOf)]; ///< Streams to communicate with the process
};
}
#endif // SLANG_PROCESS_H
|