-
Notifications
You must be signed in to change notification settings - Fork 2
/
ProcessInterface.php
182 lines (156 loc) · 4.08 KB
/
ProcessInterface.php
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
<?php
declare(strict_types=1);
/*
* This file is part of the slince/process package.
*
* (c) Slince <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Slince\Process;
use Slince\Process\Exception\LogicException;
use Slince\Process\Exception\RuntimeException;
interface ProcessInterface
{
/**
* process status,running
* @var string
*/
const STATUS_READY = 'ready';
/**
* process status,running
* @var string
*/
const STATUS_RUNNING = 'running';
/**
* process status,stopped
* @var string
*/
const STATUS_STOPPED = 'stopped';
/**
* process status,terminated
* @var string
*/
const STATUS_TERMINATED = 'terminated';
/**
* process status,exited
* @var string
*/
const STATUS_EXITED = 'exited';
/**
* Starts the process.
*/
public function start(): void;
/**
* Wait for the process exit.
*/
public function wait();
/**
* Starts and wait the process.
* @return void
*/
public function run(): void;
/**
* Stop the process.
*/
public function stop(): void;
/**
* Resume the process.
*/
public function continue(): void;
/**
* Terminate the process with an optional signal.
* @param int $signal
*/
public function terminate(int $signal = SIGKILL);
/**
* Sends a POSIX signal to the process.
*
* @param int $signal A valid POSIX signal (see https://php.net/pcntl.constants)
*
* @throws LogicException In case the process is not running
* @throws RuntimeException In case --enable-sigchild is activated and the process can't be killed
* @throws RuntimeException In case of failure
*/
public function signal(int $signal);
/**
* Gets the process id.
*
* @return int|null
*/
public function getPid(): ?int;
/**
* Checks whether the process is running.
*
* @return bool
*/
public function isRunning(): bool;
/**
* Checks if the process is stopped.
*
* @return bool true if process is stopped, false otherwise
*/
public function isStopped(): bool;
/**
* Checks if the process is terminated.
*
* @return bool true if process is terminated, false otherwise
*/
public function isTerminated(): bool;
/**
* Checks if the process is exited.
*
* @return bool true if process is exited, false otherwise
*/
public function isExited(): bool;
/**
* Gets the process status.
*
* The status is one of: ready, started, terminated.
*
* @return string The current process status
*/
public function getStatus(): string;
/**
* Returns the exit code returned by the process.
*
* @return int|null The exit status code
*/
public function getExitCode(): ?int;
/**
* Returns the exit code text returned by the process.
*
* @return string|null The exit status code text
*/
public function getExitCodeText(): ?string;
/**
* Returns the number of the signal that caused the child process to terminate its execution.
*
* It is only meaningful if hasBeenSignaled() returns true.
*
* @return int|null
*
* @throws RuntimeException In case --enable-sigchild is activated
* @throws LogicException In case the process is not terminated
*/
public function getTermSignal(): ?int;
/**
* Returns the number of the signal that caused the child process to stop its execution.
*
* It is only meaningful if hasBeenStopped() returns true.
*
* @return int|null
*
* @throws LogicException In case the process is not terminated
*/
public function getStopSignal(): ?int;
/**
* Returns true if the child process has been continued.
*
* It always returns false on Windows.
*
* @return bool
*/
public function hasBeenContinued(): bool;
}