in reply to trapping output from /dev/tty

Wow.

Sounds unfun.

The pty route seems like the way to go. But if you do need to go with anything strange (like taking over /dev/tty), consider running the program chrooted, so you can at least have /dev/tty be a local entity, not affecting the rest of the system...

A better option is likely to use LD_PRELOAD to load a different implementation of open, which returns an fd to a normal file if someone tries to open /dev/tty for output.

For example, see this, and adapt that example for open rather than time. Sorry, I don't know offhand where open is actually defined, although libc.so seems like a reasonable guess.


Mike

Edit: updated link