# Process

Neutralino's OS API (execCommand method):[ ](https://neutralino.js.org/docs/api/os#osexeccommandcommand-options)<https://neutralino.js.org/docs/api/os#osexeccommandcommand-options>

## Static class

### Process.run(command, options)

```typescript
import { Process } from '@empathize/framework';

// Executes 'rm -rf "my_folder"'
Process.run('rm -rf "my_folder"');

// Executes 'cd "my_folder" && SOME_ENV_VARIABLE="example value" rm -rf "my_folder"'
Process.run('rm -rf "my_file.txt"', {
    cwd: 'my_folder',
    env: {
        SOME_ENV_VARIABLE: 'example value'
    }
});
```

### Process.kill(id, forced)

```typescript
import { Process } from '@empathize/framework';

// SIGTERM (-15)
Process.kill(1293);

// SIGKILL (-9)
Process.kill(1293, true);
```

## Object

### process.finish(callback)

Specify callback that will be called when the process will be closed

```typescript
import { Process } from '@empathize/framework';

Process.run('some_command').then((process) => {
    process.finish((process) => {
        console.log(`Process with id ${process.id} was closed`);
    });
});
```

### process.output(callback)

Specify callback that will be called when the process will write some output

```typescript
import { Process } from '@empathize/framework';

Process.run('some_command').then((process) => {
    process.output((output, process) => {
        console.log(output);
    });
});
```

### process.kill(forced)

```typescript
import { Process } from '@empathize/framework';

Process.run('some_command').then((process) => {
    // Kill this process after 5 seconds with SIGTERM (-15)
    setTimeout(() => {
        process.kill();
    }, 5000);
});
```

### process.running()

```typescript
import { Process } from '@empathize/framework';

Process.run('some_command').then((process) => {
    setInterval(async () => {
        const running = await process.running();
        
        if (!running)
            console.log('Hey! This process was stopped!');
    }, 3000);
});
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://krypt0nn.gitbook.io/empathize/api/os-api/process.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
