Skip to main content
2 of 3
edited tags
Kusalananda
  • 355.8k
  • 42
  • 735
  • 1.1k

Command to create/connect to an I/O stream?

So I'm trying to connect to a (Lua) debugger embedded in a program by redirecting the I/O. Currently I create a pair of FIFOs for the read and write streams and connect to them using cat /tmp/dbg_write & cat > /tmp/dbg_read. This is workable and pretty straightforward, but if you don't exit everything just right you have to go back and kill the background cat command. I figured it was time for a learning experience since there seems like there must be a better way. I'm totally stumped though.

I also tried:

  • using popen("netcat -lU") to create a Unix domain socket, but pipes are unidirectional. Derp.
  • Using an existing pty. Seems promising except I don't know how to create one separate from a shell that wants to read from it.
  • Using screen to... somehow create a tty session I can interact with. (no idea...)
  • Finding an existing utility that can copy from a file/pipe to stdout while also copying from stdin to another.

Anything obvious that I'm missing?