On 15 Jul 2003 07:47:14 -0700
(Joey) wrote:
>
> I am trying to determine the PID when opening of a file handle from within
> my main perl code. Here is a snip where i call the open file handle.
>
> $infile = 'infile';
> open(IF, "tail -f $infile|") or die "Cannot open pipe $infile\n";
>
> while (<IF>) {
> do_smothing()
> }
>
> In the example below in unix the main perl code has a pid of perl variable
> $$ (PID=18629) then the open file handle has another PID, a child of the
> parent (PID = 18630)
>
> % ps -ef| grep tail
> user 18632 18455 0 10:42:06 pts/10 0:00 grep tail
> user 18630 18629 0 10:42:02 pts/10 0:00 tail -f infile
> % ps -ef| grep myscript.pl
> user 18634 18455 0 10:42:12 pts/10 0:00 grep myscript.pl
> user 18629 18455 0 10:42:02 pts/10 0:00 /usr/bin/perl ./myscript.pl
>
> Is there a way within perl to get the child PID 18630 ?
>
> Thanks in advance.
> Joey
open() should do that for you. it's in "perldoc -f open",
the bit where it says: "If the `open' involved a pipe, the
return value happens to be the pid of the subprocess."
which is nice.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drop the .thetenant to get me via mail