Redirecting output from a known file descriptors to a file is as simple as
./binary 1> ./file 2>&1
But, let's say I have a binary which might be using file descriptors other than 0
, 1
and 2
.
File descriptors 1
and 2
default to current tty
if the commands are run interactively
I'm running the binary interactively, but I think the binary has other file descriptors pointing to current tty
because I have already redirected 1
and 2
file descriptors to a file, but still some output is being written to terminal, not in the file.
It might be using n
number of other file descriptors, but I don't know which ones it's using.
I just want to redirect all these file descriptors which are pointing to current tty
to a file.
I don't care which file descriptor the binary is writing to, all streams should be redirected to this file
Something sort of like
./binary *> ./file
strace echo foobar
and count theopen
/openat
calls. When you mess with these, things simply won't work. I think you really need to describe what it is that you're planning to do, and which problem you want to solve with that.