Hi there! Are you looking for the official Deno documentation? Try docs.deno.com for all your Deno learning needs.

Deno.Process

class Process<T extends RunOptions = RunOptions> {
readonly pid: number;
readonly rid: number;
readonly stderr: T["stderr"] extends "piped" ? Reader & Closer & {
readable: ReadableStream<Uint8Array>;
}
: (Reader & Closer & {
readable: ReadableStream<Uint8Array>;
}
)
| null
;
readonly stdin: T["stdin"] extends "piped" ? Writer & Closer & {
writable: WritableStream<Uint8Array>;
}
: (Writer & Closer & {
writable: WritableStream<Uint8Array>;
}
)
| null
;
readonly stdout: T["stdout"] extends "piped" ? Reader & Closer & {
readable: ReadableStream<Uint8Array>;
}
: (Reader & Closer & {
readable: ReadableStream<Uint8Array>;
}
)
| null
;
 
close(): void;
kill(signo: Signal): void;
output(): Promise<Uint8Array>;
status(): Promise<ProcessStatus>;
stderrOutput(): Promise<Uint8Array>;
}

§Type Parameters

§Properties

§
pid: number
[src]
§
rid: number
[src]
§
stderr: T["stderr"] extends "piped" ? Reader & Closer & {
readable: ReadableStream<Uint8Array>;
}
: (Reader & Closer & {
readable: ReadableStream<Uint8Array>;
}
)
| null
[src]
§
stdin: T["stdin"] extends "piped" ? Writer & Closer & {
writable: WritableStream<Uint8Array>;
}
: (Writer & Closer & {
writable: WritableStream<Uint8Array>;
}
)
| null
[src]
§
stdout: T["stdout"] extends "piped" ? Reader & Closer & {
readable: ReadableStream<Uint8Array>;
}
: (Reader & Closer & {
readable: ReadableStream<Uint8Array>;
}
)
| null
[src]

§Methods

§
close(): void
[src]
§
kill(signo: Signal): void
[src]

Send a signal to process.

const p = Deno.run({ cmd: [ "sleep", "20" ]});
p.kill("SIGTERM");
p.close();
§
output(): Promise<Uint8Array>
[src]

Buffer the stdout until EOF and return it as Uint8Array.

You must set stdout to "piped" when creating the process.

This calls close() on stdout after its done.

§
status(): Promise<ProcessStatus>
[src]

Wait for the process to exit and return its exit status.

Calling this function multiple times will return the same status.

Stdin handle to the process will be closed before waiting to avoid a deadlock.

If stdout and/or stderr were set to "piped", they must be closed manually before the process can exit.

To run process to completion and collect output from both stdout and stderr use:

const p = Deno.run({ cmd: [ "echo", "hello world" ], stderr: 'piped', stdout: 'piped' });
const [status, stdout, stderr] = await Promise.all([
  p.status(),
  p.output(),
  p.stderrOutput()
]);
p.close();
§
stderrOutput(): Promise<Uint8Array>
[src]

Buffer the stderr until EOF and return it as Uint8Array.

You must set stderr to "piped" when creating the process.

This calls close() on stderr after its done.