public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jim Nance <jlnance@sdf.lonestar.org>
To: Arijit Das <Arijit.Das@synopsys.com>
Cc: 7eggert@gmx.de, linux-kernel@vger.kernel.org
Subject: Re: Does Linux has File Stream mapping support...?
Date: Mon, 21 Nov 2005 09:18:37 +0000	[thread overview]
Message-ID: <20051121091837.GA2619@SDF.LONESTAR.ORG> (raw)
In-Reply-To: <7EC22963812B4F40AE780CF2F140AFE920906A@IN01WEMBX1.internal.synopsys.com>

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];
    pipe(pfd);

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

-- 
jlnance@sdf.lonestar.org
SDF Public Access UNIX System - http://sdf.lonestar.org

  parent reply	other threads:[~2005-11-21  9:19 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-11-18 12:51 Does Linux has File Stream mapping support...? Arijit Das
2005-11-18 12:59 ` Bas Westerbaan
2005-11-18 13:01   ` Bas Westerbaan
2005-11-18 14:28     ` Dick Streefland
2005-11-18 19:06 ` Bill Davidsen
2005-11-18 19:39 ` Lennart Sorensen
2005-11-21  9:18 ` Jim Nance [this message]
     [not found] <5abPs-7Da-41@gated-at.bofh.it>
2005-11-18 12:30 ` Bodo Eggert
  -- strict thread matches above, loose matches on Subject: below --
2005-11-18 10:38 Arijit Das
2005-11-18 20:14 ` James Courtier-Dutton
2005-11-18 20:41   ` linux-os (Dick Johnson)
2005-11-19  4:27 ` Herbert Xu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20051121091837.GA2619@SDF.LONESTAR.ORG \
    --to=jlnance@sdf.lonestar.org \
    --cc=7eggert@gmx.de \
    --cc=Arijit.Das@synopsys.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox