in reply to Re: How to know STDOUT associated with a process pid
in thread How to know STDOUT associated with a process pid

If I am understanding it correctly this would require a file descriptor of the output file, since I am invoking the perl code from unix command line or a shell script , how can I get the file descriptor of the filename which will be created by the redirected output of the invoked perl program inside that perl program ? The perl script has been invoked via shell scripts at several places and I am going to modify the perl script to know where its output is being redirected by invoking it through unix command line( or shell script ). Please clarify if I am missing something.
  • Comment on Re^2: How to know STDOUT associated with a process pid

Replies are listed 'Best First'.
Re^3: How to know STDOUT associated with a process pid
by MidLifeXis (Monsignor) on Feb 06, 2009 at 18:08 UTC

    STDOUT can get you a file descriptor of some sort, right?

    It has been many years since I have done this, but the -t test in the shell can tell if it is attached to a file or a pty, so I would guess that you can get to the inode (if applicable) attached to the STDOUT as well.

    Some of the other responses on this posting also have good ideas, some even with already written solutions (even the negative responses have some good stuff in them if you dig a little). I would pursue the fstat stuff only if the other stuff on this thread didn't pan out. In fact, it would not surprise me if some of the other solutions even used fstat behind the scenes.

    Good luck

    --MidLifeXis