From: Aharon Robbins <address@hidden>
Date: Tue, 25 Dec 2012 22:51:05 +0200
Cc: address@hidden, address@hidden,
address@hidden, address@hidden
char buf[100]; /* say */
sprintf(buf, "/dev/fd/%d", save_fd);
fp = freopen(buf, "w", stdout);
close(save_fd);
save_fd = -1;
Ta da!
Details left as an exercise for the reader.
But /dev/fd/N is not portable :-(
Solaris, Linux, *BSD, Mac OS X, Cygwin. Portable enough for me
But obviously not for me.
I suspect that some combination of dup, fileno, freopen, fdopen, and
*stdout = *fp / *fp = *stdout could be made to work on systems not
supporting /dev/fd.
Maybe. Me, I don't eben understand what you are trying to accomplish,
as you'd be mv'ing the output anyway.