| Conditions | 2 |
| Paths | 2 |
| Total Lines | 18 |
| Code Lines | 7 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 6 |
| CRAP Score | 2.0116 |
| Changes | 0 | ||
| 1 | <?php |
||
| 54 | 82 | protected function osProcessIsRunning($needle) |
|
|
1 ignored issue
–
show
|
|||
| 55 | { |
||
| 56 | // get process status. the "-ww"-option is important to get the full output! |
||
| 57 | 82 | exec('ps aux -ww', $process_status); |
|
| 58 | |||
| 59 | |||
| 60 | // search $needle in process status |
||
| 61 | 82 | $result = array_filter($process_status, |
|
| 62 | function($var) use ($needle) |
||
| 63 | 82 | { return strpos($var, $needle); }); |
|
| 64 | |||
| 65 | |||
| 66 | // if the result is not empty, the needle exists in running processes |
||
| 67 | 82 | if (!empty($result)) { |
|
| 68 | return true; |
||
| 69 | } |
||
| 70 | |||
| 71 | 82 | return false; |
|
| 72 | } |
||
| 74 |