Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
May 27, 2005, 6:31 pm
rate this thread
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 :-)
Re: finding 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.
In recent Perl the above is redundant - open() autovivifies.
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 ..........