Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^4: Easy way to check if a file is open needed.

by haukex (Archbishop)
on Apr 09, 2019 at 08:17 UTC ( [id://1232341]=note: print w/replies, xml ) Need Help??


in reply to Re^3: Easy way to check if a file is open needed.
in thread Easy way to check if a file is open needed.

The time hog is lsof, which takes about 13 seconds to run. ... I understand grep will return 0 if it finds something.

Note that it's possible to get lsof to only look in one directory tree with its +D option, although the manpage does note that it can consume a fair amount of memory, so you might want to keep an eye on that in testing.

As for running external programs from Perl, I've written about that a fair amount, e.g. here - in this case, it seems like capturex from IPC::System::Simple might be a good replacement for qx// (backticks) - if the processes you're running are expected to return either 0 or 1 and that's not an error, then you can specify [0,1] as the first argument.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1232341]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (4)
As of 2024-03-29 00:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found