# Process Module Examples

This directory contains examples demonstrating the Process module functionality.

## Available Functions

### Command Execution
- `run(cmd)` - Run a command and return stdout (simple usage)
- `cmd(cmd)` - Create a command builder for advanced options
- `run_command(cmd)` - Run command, return CommandResult (legacy)
- `run_silent(cmd)` - Run command silently (legacy)

### Command Builder Methods
When using `cmd()`, chain these methods:
- `.silent()` - Suppress output
- `.ignore_error()` - Don't fail on error
- `.log()` - Enable logging
- `.execute()` - Execute the command

### Process Management
- `which(cmd)` - Find command path in PATH
- `kill(pattern)` - Kill processes matching pattern
- `process_list(pattern)` - List processes matching pattern
- `process_get(pattern)` - Get single process info

### CommandResult Properties
- `.stdout` - Standard output
- `.stderr` - Standard error
- `.success` - Whether command succeeded
- `.code` - Exit code

### ProcessInfo Properties
- `.pid` - Process ID
- `.name` - Process name
- `.memory` - Memory usage
- `.cpu` - CPU usage

## Examples

- `01_run_commands.rhai` - Basic command execution with run()
- `02_command_builder.rhai` - Advanced command builder with cmd()
- `03_process_management.rhai` - Process listing and management

## Running Examples

```bash
cd packages/os
herodo rhaiexamples/process/01_run_commands.rhai
herodo rhaiexamples/process/02_command_builder.rhai
herodo rhaiexamples/process/03_process_management.rhai
```
