Skip to content

Commit e3ebb8a

Browse files
authored
Merge pull request #2 from mozartk/master
update readme file
2 parents 63f4678 + 996d6aa commit e3ebb8a

File tree

7 files changed

+28
-12
lines changed

7 files changed

+28
-12
lines changed

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,20 @@ if($process){
6666
[cpu_time] => 0:00:00
6767
[window_title] => N/A
6868
)
69+
70+
returns the following on macOS
71+
[0] => Array
72+
(
73+
[name] => (sh)
74+
[pid] => 62951
75+
[session_name] =>
76+
[session] => 0
77+
[mem_used] => 0 KB
78+
[status] => RUNNING
79+
[username] => username
80+
[cpu_time] => 0:00.00
81+
[window_title] =>
82+
)
6983
*/
7084
}else{
7185
// process was not found.

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"symfony/process": "~2.3|~3.0"
2222
},
2323
"require-dev": {
24-
"phpunit/phpunit": "~4.0|~5.0"
24+
"phpunit/phpunit": "~3.7|~4.0|~5.0"
2525
},
2626
"autoload": {
2727
"psr-4": {

src/ProcessHandler/Drivers/MacOS.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,13 @@ private function parse ($output) {
4141
$op = explode("\n", $output);
4242

4343

44-
$processes = [];
44+
$processes = array();
4545
foreach ($op as $k => $item) {
4646
if ($k < 1)
4747
continue;
4848

4949
$item = explode(" ", preg_replace('!\s+!', ' ', trim($item)));
50-
$line = [];
50+
$line = array();
5151
foreach ($item as $i) {
5252
if ($i != '')
5353
$line[] = $i;

src/ProcessHandler/Drivers/Unix.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,13 @@ function getProcessByPid ($pid) {
3838
private function parse ($output) {
3939
$op = explode("\n", $output);
4040

41-
$processes = [];
41+
$processes = array();
4242
foreach ($op as $k => $item) {
4343
if ($k < 1)
4444
continue;
4545

4646
$item = explode(" ", $item);
47-
$line = [];
47+
$line = array();
4848
foreach ($item as $i) {
4949
if ($i != '')
5050
$line[] = $i;

src/ProcessHandler/Drivers/Windows.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,20 +56,20 @@ function getProcessByProcessName ($processName) {
5656
private function parseOutput ($output) {
5757
$op = explode("\n", $output);
5858
if (count($op) == 1) {
59-
return [];
59+
return array();
6060
}
6161
$sessions = explode(" ", $op[1]);
62-
$cs = [];
62+
$cs = array();
6363
foreach ($sessions as $session) {
6464
$cs[] = strlen($session);
6565
}
66-
$processes = [];
66+
$processes = array();
6767

6868
foreach ($op as $k => $o) {
6969
if ($k < 2)
7070
continue;
7171

72-
$p = [
72+
$p = array(
7373
'name' => trim(substr($o, 0, $cs[0] + 1)),
7474
'pid' => trim(substr($o, $cs[0] + 1, $cs[1] + 1)),
7575
'session_name' => trim(substr($o, $cs[0] + $cs[1] + 2, $cs[2] + 1)),
@@ -79,7 +79,7 @@ private function parseOutput ($output) {
7979
'username' => trim(substr($o, $cs[0] + $cs[1] + $cs[2] + $cs[3] + $cs[4] + $cs[5] + 6, $cs[6] + 1)),
8080
'cpu_time' => trim(substr($o, $cs[0] + $cs[1] + $cs[2] + $cs[3] + $cs[4] + $cs[5] + $cs[6] + 7, $cs[7] + 1)),
8181
'window_title' => trim(substr($o, $cs[0] + $cs[1] + $cs[2] + $cs[3] + $cs[4] + $cs[5] + $cs[6] + $cs[7] + 8, $cs[8] + 1)),
82-
];
82+
);
8383

8484
$processes[] = new Process2($p['name'], $p['pid'], $p['session_name'], $p['session'], $p['mem_used'], $p['status'],
8585
$p['username'], $p['cpu_time'], $p['window_title']);

src/ProcessHandler/Process.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ public function __construct ($name, $pid, $session_name, $session, $mem_used, $s
5757
* @return bool
5858
*/
5959
public function isRunning () {
60-
return (new ProcessHandler())->isRunning($this->getPid());
60+
$process = new ProcessHandler();
61+
return $process->isRunning($this->getPid());
6162
}
6263

6364
/**

test.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
$process->start();
88
$pid = $process->getPid();
99
echo $pid;
10-
$process = $processHandler->getProcess(12796);
10+
echo "\n";
11+
$process = $processHandler->getProcess($pid);
1112
print_r($process);
1213
print_r($process->isRunning());
1314
print_r($process->getWindowTitle());

0 commit comments

Comments
 (0)