File tree Expand file tree Collapse file tree 2 files changed +16
-24
lines changed Expand file tree Collapse file tree 2 files changed +16
-24
lines changed Original file line number Diff line number Diff line change @@ -73,7 +73,7 @@ private function closePipes()
73
73
fclose ($ this ->pipes [self ::STDERR_DESCRIPTOR_KEY ]);
74
74
}
75
75
76
- public function execute (bool $ blocking = false )
76
+ public function execute ()
77
77
{
78
78
if ($ this ->isRunning ()) {
79
79
throw new RuntimeException ('Process is already running ' );
@@ -91,10 +91,6 @@ public function execute(bool $blocking = false)
91
91
$ this ->updateStatus ();
92
92
93
93
$ this ->startTime = microtime (true );
94
-
95
- if ($ blocking ) {
96
- $ this ->wait ();
97
- }
98
94
}
99
95
100
96
public function getOutput ()
@@ -112,29 +108,15 @@ public function getExitCode()
112
108
return $ this ->status ['exitcode ' ];
113
109
}
114
110
115
- public function checkTimeout ()
116
- {
117
- if ($ this ->timeout && $ this ->timeout < microtime (true ) - $ this ->startTime ) {
118
- $ this ->stop ();
119
- }
120
-
121
- return $ this ->status ;
122
- }
123
-
124
- public function wait ()
111
+ public function isRunning ()
125
112
{
126
- while ($ this ->isRunning ()) {
127
- usleep (1000 );
128
- $ this ->checkTimeout ();
129
- $ this ->updateStatus ();
113
+ if (!$ this ->status ) {
114
+ return false ;
130
115
}
131
116
132
- return $ this ->status ;
133
- }
117
+ $ this ->updateStatus ();
134
118
135
- public function isRunning ()
136
- {
137
- return $ this ->status && $ this ->status ['running ' ];
119
+ return $ this ->status ['running ' ];
138
120
}
139
121
140
122
public function getProcessId ()
Original file line number Diff line number Diff line change @@ -19,4 +19,14 @@ public function test_get_output()
19
19
$ shell ->execute ();
20
20
$ this ->assertSame ("hello \n" , $ shell ->getOutput ());
21
21
}
22
+
23
+ public function test_get_process_id ()
24
+ {
25
+ $ shell = new Shell ("echo hello " );
26
+ $ shell ->execute ();
27
+ echo '<pre> ' ;
28
+ print_r ($ shell ->getProcessId ());
29
+ exit ;
30
+ $ this ->assertInternalType ("int " , $ shell ->getProcessId ());
31
+ }
22
32
}
You can’t perform that action at this time.
0 commit comments