I want the input/output (tty) of a binary debugged in GDB (running in Docker) as a NodeJS stream.
GDB can seperate its output and the binary's output by using the tty <tty>
command. I want to interact with this TTY, but it is in a Docker container. Is there anyway to expose the TTY?
So far, I've tried chvt
while exec'ing from the container (through Dockerode) and reading the output stream, but it doesn't work.
Running GDB in container with gdb -i=mi --tty=<some tty>
I want to attach using e.g. exec:
let exec:Exec = await container.exec({
AttachStdin: true,
AttachStdout: true,
AttachStderr: true,
Cmd: ['chvt', '69'],
Tty: true
});
let execProc = await exec.start({Tty: true});
let sock = execProc.output.connection;
sock.pipe(<somewhere>); //tty of binary running in GDB can be interacted via pipe
let containerExecStream = async (container: Container,cmd: string[]) => {
let exec = await container.exec({
AttachStdin: true,
AttachStdout: true,
AttachStderr: true,
Tty: true,
Cmd:['bash', '-c', 'socat pty,raw,echo=0,link=/dev/gdbout,waitslave -']});
let out = await exec.start({Tty: true});
return <Socket>out.output.connection;
}