in reply to Re^2: capturing output of system call inside a thread
in thread capturing output of system call inside a thread

I want outputs (both STDOUT and STDERR) and any output from system() of each of these "processes" to be captured in separate files preferably with STDOUT and STDERR outputs arranged properly.

What do you mean by:

  1. "any output from system()"?

    system doesn't produce output.

    Programs run using system produce output; but you've already said you want to capture that.

    So what other output ("produced by system()") are you expecting?

  2. "with STDOUT and STDERR outputs arranged properly"?

    stdout is usually buffered; whereas stderr is usually unbuffered; which means that stuff written to stderr often appears on the console before stuff that was written to stdout chronologically earlier in the execution of the program.

    There is nothing that can be done from outside of the program to influence the that.

    If you have access to the sources of the external programs you are running; you can ensure that both streams are unbuffered; but that has nothing to do with threading, or the perl code that is invoking those programs.

I think I can suggest something to achieve your goals; but I need you to answer those two questions first.


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
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". I knew I was on the right track :)
In the absence of evidence, opinion is indistinguishable from prejudice.
I'm with torvalds on this Agile (and TDD) debunked I told'em LLVM was the way to go. But did they listen!
  • Comment on Re^3: capturing output of system call inside a thread

Replies are listed 'Best First'.
Re^4: capturing output of system call inside a thread
by that_guy (Novice) on Sep 03, 2015 at 19:35 UTC
    Thanks for the reply again.

    1. Sorry I was imprecise. I've meant that I want to capture output of the program that is being run by system call: STDOUT and STDERR, as well as STDOUT and STDERR produced by perl code in that "process".

    2. You are correct is saying I can't control external program buffering from my perl script. I just want to see in my log file the same thing that I would see on the screen if I were to run that program independently from the command line.

      I want to capture output of the program that is being run by system call: STDOUT and STDERR, as well as STDOUT and STDERR produced by perl code in that "process".

      What is the difference between: output of the program that is being run by system call; and STDOUT and STDERR produced by perl code in that "process"?

      Aren't they the same thing?


      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      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". I knew I was on the right track :)
      In the absence of evidence, opinion is indistinguishable from prejudice.
      I'm with torvalds on this Agile (and TDD) debunked I told'em LLVM was the way to go. But did they listen!

        Geez, you guys!

        @BrowserUK: Maybe he means what he said in his first post:

        Each of the worker threads is essentially independent and can run perl code as well as do system() calls.

        @that_guy: Maybe he wanted you to explain specifically what you are doing (e.g. give an example of some of the "perl code" each thread is supposed to run) when he said:

        if you can describe what it is that you need to do; rather than how you are currently trying to do "it"; then I might be able to help

        You're welcome :-) I'm hoping to learn something here . . .

        The way forward always starts with a minimal test.