Skip to content

Commit

Permalink
docs updated
Browse files Browse the repository at this point in the history
  • Loading branch information
craftpip committed Apr 7, 2017
1 parent c2e697b commit 056c462
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
30 changes: 22 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,25 @@ use \Symfony\Component\Process\Process;
$processHandler = new ProcessHandler();

// Spawn a process and check if a process by its pid exists.
$process = new Process('ls');
$process->start();
$pid = $process->getPid(); // 8378
$processes = $processHandler->api->getProcessByPid($pid);
if(count($processes)){
$symfonyProcess = new Process('ls');
$symfonyProcess->start();
$pid = $symfonyProcess->getPid(); // 8378

$process = $processHandler->getProcess($pid);
if($process){
$name = $process->getName();
$pid = $process->getPid();
$mem_used = $process->getMemUsed();
$cpu_time = $process->getCpuTime();
$session = $process->getSession();
$session_name = $process->getSessionName();
$status = $process->getStatus();
$username = $process->getUsername();
$window_title = $process->getWindowTitle();
$is_running = $process->isRunning();

/*
Examples
returns the following on UNIX
[0] => Array
(
Expand Down Expand Up @@ -60,14 +73,15 @@ if(count($processes)){


// get all processes
$allProcesses = $processHandler->api->getAllProcesses();
$allProcesses = $processHandler->getAllProcesses();
```

## Methods
```php
$processHandler = new ProcessHandler();
$processHandler->api->getAllProcesses();
$processHandler->api->getProcessByPid($pid);
$processHandler->getAllProcesses();
$processHandler->getProcess($pid);
$processHandler->isRunning($pid);
```

## Installation
Expand Down
3 changes: 2 additions & 1 deletion test.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@
$process = $processHandler->getProcess(12796);
print_r($process);
print_r($process->isRunning());
print_r($process->getWindowTitle());
print_r($process->getWindowTitle());

0 comments on commit 056c462

Please sign in to comment.