Preparing search index...

    Class which allows you to trigger a subproccess outside of Lens Studio (e.g. a command line command).

        const Subprocess = await import('LensStudio:Subprocess');

    // --- Async spawn via Subprocess.create ---
    // Subprocess.create(command, args, options) returns a Subprocess instance.
    // Call .start() to begin execution. Connect signals for events.
    const proc = Subprocess.Subprocess.create('echo', ['async hello'], {} as any);

    this.connections.push(
    proc.onStart.connect(() => {
    console.log(`Subprocess started: ${proc.command}`);
    })
    );

    this.connections.push(
    proc.stdout.connect((data: Editor.Buffer) => {
    console.log(`stdout received: ${data.toString().length} bytes`);
    })
    );

    this.connections.push(
    proc.stderr.connect((data: Editor.Buffer) => {
    console.log(`stderr received: ${data.toString().length} bytes`);
    })
    );

    this.connections.push(
    proc.onExit.connect((exitCode: number, exitStatus: number) => {
    console.log(`Subprocess exited: code=${exitCode}, status=${exitStatus}`);
    })
    );

    this.connections.push(
    proc.onError.connect((errorCode: number) => {
    console.log(`Subprocess error: ${errorCode}`);
    })
    );

    this.connections.push(
    proc.onStateChange.connect((state: number) => {
    // 0=NotRunning, 1=Starting, 2=Running
    console.log(`Subprocess state changed: ${state}`);
    })
    );

    proc.start();

    // --- Synchronous spawn ---
    const syncResult = Subprocess.spawnSync('echo', ['sync hello'], {} as any);
    console.log(`spawnSync exitCode: ${syncResult.exitCode}`);

    // --- stdin (Writable) ---
    // proc.stdin is a Writable; use proc.stdin.write(data) to send input.
    console.log(`stdin available: ${proc.stdin !== undefined}`);

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    command: string

    The command for the subprocess.

    onError: signal1<number, void>

    A handle for getting callback when a subprocess' state has errored.

    onExit: signal2<number, number, void>

    A handle for getting callback when a subprocess' state has exited.

    Callback will receive two arguments in order: Exit code (usually 0 means success) Exit status (0 on normal exit, 1 on crash)

    onStart: signal0<void>

    A handle for getting callback when a subprocess is started

    onStateChange: signal1<number, void>

    A handle for getting callback when a subprocess' state has changed.

    Callback will receive a number describing a state.

    Possible states: Not running 0 Starting 1 Running 2

    stderr: signal1<Buffer, void>

    A handle for getting callback when a subprocess' state has received stderr.

    stdin: Writable

    A handle for getting callback when a subprocess' state has received stdin.

    stdout: signal1<Buffer, void>

    A handle for getting callback when a subprocess' state has received stdout.

    Methods

    • Returns true if the object is of the specified type.

      Parameters

      • type: string

      Returns boolean

    • Kills a subprocess.

      Returns void

    • Starts a subprocess.

      Returns void