|We don't bite newbies here... much|
Finding out by one process a filename opened by another process.by humble (Acolyte)
|on Aug 01, 2012 at 09:41 UTC||Need Help??|
humble has asked for the
wisdom of the Perl Monks concerning the following question:
I'm looking for PERL right way decision regarding finding out by one process a fullpath to a file opened by another process.
I have a PERL script w/ several BASH code insertions. I want to rewrite some BASH code in PERL - hence this question.
This script waits (w/ the help of Term::ReadKey module) for key pressings, - undertaking file processing (say, file removal from FS). The full path to that file now is cathed as follows:
regexp for PID
regexp for a full path to the file (to avoid some encodings troubles)
from a forked process being started w/
system( "/usr/bin/mkfifo $pipe_file && $script $pid $params &" );
- though not the best solution regarding PERL, but worked - apposed to PERL's fork function - haw pipe behaved wrong in some circumstances.
Finally, my question is, What's the best PERL practics - catching full path to a filename, opened now by one process and cacthed another? F.e.: process A opened a file, how process B can get that file full path? - Both pocesses are run on same host, under same user. Both proccess has pipe filename, or may have an ID - thus identifying itself having relation one w/ another.
Thank You for Your time and wisdom.