property
Subprocess.terminal
readonly terminal: undefined | Terminal
The terminal attached to this subprocess, if spawned with the terminal option. Returns undefined if no terminal was attached.
When a terminal is attached, stdin, stdout, and stderr return null. Use terminal.write() and the data callback instead.
const proc = Bun.spawn(["bash"], {
terminal: { data: (term, data) => console.log(data.toString()) },
});
proc.terminal?.write("echo hello\n");