Re: Does Linux has File Stream mapping support...?

From: Jim Nance
Date: Mon Nov 21 2005 - 04:19:50 EST

On Fri, Nov 18, 2005 at 06:21:59PM +0530, Arijit Das wrote:
> Ye...I know of tee.
> But the issue here is I have a HUGE Compiler (an Simulation tool)
> in which thousands of places there are "printf" statements to print
> messages to STDOUT stream. Now, a requirement came up which needs
> all those messages thrown to STDOUT also to be logged in a LOGFILE
> (in addition to STDOUT). Yes, this can be done through tee...but
> the usage model of the compiler doesn't leave that possibility open
> for me.

You have the source code for the compiler? Put a call to something
like this at the beginning of main(). I'm leaving out the error handling,
you can write that ;)

void startlogging()
pid_t tpid;
int pfd[2];

if(tpid==0) {
/* child process */
dup2(pfd[0], 0);
execl("/usr/bin/tee", "logfile");
} else {
dup2(pfd[1], 1);

SDF Public Access UNIX System -
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at