in reply to Re: Pipe Problem
in thread Pipe Problem

Thank you for your response. I can modify the C program to output the trailing spaces. Is there a way I can find out how big my system's buffer is so I can output the necessary trailing spaces?

Replies are listed 'Best First'.
Re^3: Pipe Problem
by BrowserUk (Patriarch) on Jul 22, 2007 at 22:43 UTC

    Sorry. I assumed that you did not have the source to the C program. If you can modify the source, you should be able to call the C function flush() (or fflush()) on stdout/stderr after printing each progress message.


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
      No, the C program is working correctly. If I run it from the command line without calling it from PERL, it see the percent completed being printed to the screen as the C program progressed. +::010 (some times later) +::020 +::030 +::040 +::050 +::060 +::070 +::080 +::090 +::100 However, when I run the Perl script and invoking the C program from withing PERL, all the above lines get printed out at the same time after the C program are done. I can monitor this because I have another terminal connected to the database where the C program are sending requests and only when the C program have finished all its requests and disconnected after a few hours do I see all the above lines get printed to the screen all at once.
        That would be because when you run your executable connected to terminal (STDOUT) it doesn't buffer...well it's actually line buffered. but when you run it and connect it to a pipe, then it's buffering differently (probably 1024 bytes or such but don't know for sure.) If you force flush as outlined, the problem will disappear. The problem is introduced by the OS handling of pipes..not the C program (executable) neither perl is at fault.
        the hardest line to type correctly is: stty erase ^H