finding the PID of a process running as an anonymous pipe

R

Richard

I need to find the PID of a process running as an anonymous pipe, that is I
have this code

$fh = new FileHandle;
open($fh, "tail -f $filename |") or die ..........

I want to get the PID of the tail -f process when runing under linux, I
could do it by looking at the output of ps -fwu $userid | grep "tail -f
$filename", but that seems like over kill :)

Thanks.
Richard.
 
A

Anno Siegel

Richard said:
I need to find the PID of a process running as an anonymous pipe, that is I
have this code

$fh = new FileHandle;
open($fh, "tail -f $filename |") or die ..........

I want to get the PID of the tail -f process when runing under linux, I
could do it by looking at the output of ps -fwu $userid | grep "tail -f
$filename", but that seems like over kill :)

"perldoc -f open" will answer that. Also see "perldoc -q tail".

Anno
 
B

Brian McCauley

Richard said:
I need to find the PID of a process running as an anonymous pipe,

I know you've no RTDMed at Anno's suggestion so I won't adderess that.
$fh = new FileHandle;

In recent Perl the above is redundant - open() autovivifies.
open($fh, "tail -f $filename |") or die ..........

In recent perl rather than combining the mode and all the exec()
arguments into a string and having perl (or even /bin/sh) pull them
appart again, you can acually give them as a list. This is far cleaner.

open($fh, '-|', 'tail', '-f', $filename) or die ..........
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,900
Latest member
Nell636132

Latest Threads

Top