Skip to main content
Retrieves detailed information about a specific background process by its ID.

Method Signature

await sandbox.getProcess(
  id: string,
  sessionId?: string
): Promise<Process | null>

Parameters

id
string
required
The process ID to retrieve
sessionId
string
Optional session ID. If not provided, the default session is used.

Returns

Process
Process | null
Process object if found, or null if the process doesn’t exist

Examples

Get process by ID

const process = await sandbox.getProcess('dev-server');

if (process) {
  console.log('Status:', process.status);
  console.log('Started:', process.startTime);
} else {
  console.log('Process not found');
}

Check if process is running

const process = await sandbox.getProcess('my-process');

if (process && process.status === 'running') {
  console.log('Process is running with PID:', process.pid);
}

Get exit code of completed process

const process = await sandbox.getProcess('batch-job');

if (process && process.status === 'completed') {
  console.log('Process completed with exit code:', process.exitCode);
}

Build docs developers (and LLMs) love