teeing parent+childs output

Discussion in 'C Programming' started by -H, Aug 18, 2003.

  1. -H

    -H Guest

    Hi,

    I have a "parent" C program that forks off a "child" C program.
    Both the parent and the child print information to both stdout and
    stderr.

    I would like to redirect the parent and childs output to both stdout
    and an output logfile (in effect, a "tee" like behavior).

    I've tried several things with pipes and freopens, but I always seem
    to get data out of synch. :(

    Any help on this would be greatly appreciated!
    Please cc replies to .
    Thanks in advance.

    - H
     
    -H, Aug 18, 2003
    #1
    1. Advertising

  2. -H

    Derk Gwen Guest

    (-H) wrote:
    # Hi,
    #
    # I have a "parent" C program that forks off a "child" C program.
    # Both the parent and the child print information to both stdout and
    # stderr.
    #
    # I would like to redirect the parent and childs output to both stdout
    # and an output logfile (in effect, a "tee" like behavior).
    #
    # I've tried several things with pipes and freopens, but I always seem
    # to get data out of synch. :(

    Each process has its own buffers. To force output to a device, you need to use
    fflush or turn off bufferring with setvbuf. This can slow the program down.

    --
    Derk Gwen http://derkgwen.250free.com/html/index.html
    I have no idea what you just said.
    I get that alot.
     
    Derk Gwen, Aug 19, 2003
    #2
    1. Advertising

  3. -H

    Bryan Donlan Guest

    -----BEGIN PGP SIGNED MESSAGE-----
    Hash: SHA1

    - -H wrote:

    > Hi,
    >
    > I have a "parent" C program that forks off a "child" C program.
    > Both the parent and the child print information to both stdout and
    > stderr.


    forking isn't in the ISO C specification. Try comp.unix.programmer.
    - --
    Freenet distribution not available
    You're not an alcoholic unless you go to the meetings.

    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v1.2.2 (GNU/Linux)

    iD8DBQE/QYiFx533NjVSos4RAm4EAJ42knygi5fzBMic+nW1KSbZm973CQCdER2+
    lEG1ZU/uEMh0YUx36U/KL54=
    =+hIu
    -----END PGP SIGNATURE-----
     
    Bryan Donlan, Aug 19, 2003
    #3
  4. -H

    Jack Klein Guest

    On Tue, 19 Aug 2003 00:06:12 -0000, Derk Gwen <>
    wrote in comp.lang.c:

    > (-H) wrote:
    > # Hi,
    > #
    > # I have a "parent" C program that forks off a "child" C program.
    > # Both the parent and the child print information to both stdout and
    > # stderr.
    > #
    > # I would like to redirect the parent and childs output to both stdout
    > # and an output logfile (in effect, a "tee" like behavior).
    > #
    > # I've tried several things with pipes and freopens, but I always seem
    > # to get data out of synch. :(
    >
    > Each process has its own buffers. To force output to a device, you need to use
    > fflush or turn off bufferring with setvbuf. This can slow the program down.


    Can you cite the section in either the C or C++ standard that defines
    what each process has? If not, don't post this drivel here.

    --
    Jack Klein
    Home: http://JK-Technology.Com
    FAQs for
    comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
    comp.lang.c++ http://www.parashift.com/c -faq-lite/
    alt.comp.lang.learn.c-c++ ftp://snurse-l.org/pub/acllc-c /faq
     
    Jack Klein, Aug 19, 2003
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. -H
    Replies:
    3
    Views:
    363
    Jack Klein
    Aug 19, 2003
  2. Guillermo D. Polonsky

    Keep javascript reference to the childs

    Guillermo D. Polonsky, Jul 11, 2006, in forum: ASP .Net
    Replies:
    2
    Views:
    417
    =?ISO-8859-1?Q?G=F6ran_Andersson?=
    Jul 11, 2006
  3. Markus Franz

    Processes and their childs

    Markus Franz, Dec 21, 2004, in forum: Python
    Replies:
    1
    Views:
    292
    Jeff Epler
    Dec 21, 2004
  4. Replies:
    2
    Views:
    450
    Chris Uppal
    Sep 19, 2006
  5. Replies:
    3
    Views:
    213
Loading...

Share This Page