The process state of a "LensStudio:Subprocess".spawn or "LensStudio:Subprocess".spawnSync.
const Sub = await import('LensStudio:Subprocess'); // ProcessState describes the current state of a spawned subprocess: // Idle (0) — not running // Starting (1) — initializing // Running (2) — actively running const proc = Sub.spawn('echo', ['hello'], {} as any); // Monitor state transitions via onStateChange signal this.connections.push( proc.onStateChange.connect((state: number) => { if (state === Sub.ProcessState.Idle) { console.log('Process is idle'); } else if (state === Sub.ProcessState.Starting) { console.log('Process is starting'); } else if (state === Sub.ProcessState.Running) { console.log('Process is running'); } }) ); this.connections.push( proc.onExit.connect((exitCode: number, exitStatus: number) => { console.log('Process exited with code:', exitCode, 'status:', exitStatus); }) ); Copy
const Sub = await import('LensStudio:Subprocess'); // ProcessState describes the current state of a spawned subprocess: // Idle (0) — not running // Starting (1) — initializing // Running (2) — actively running const proc = Sub.spawn('echo', ['hello'], {} as any); // Monitor state transitions via onStateChange signal this.connections.push( proc.onStateChange.connect((state: number) => { if (state === Sub.ProcessState.Idle) { console.log('Process is idle'); } else if (state === Sub.ProcessState.Starting) { console.log('Process is starting'); } else if (state === Sub.ProcessState.Running) { console.log('Process is running'); } }) ); this.connections.push( proc.onExit.connect((exitCode: number, exitStatus: number) => { console.log('Process exited with code:', exitCode, 'status:', exitStatus); }) );
Process is not running.
Process is actively running.
Process is initializing and starting up.
The process state of a "LensStudio:Subprocess".spawn or "LensStudio:Subprocess".spawnSync.
Example