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.
In reply to Re^4: Easy way to check if a file is open needed.
by haukex
in thread Easy way to check if a file is open needed.
by Apt_Addiction
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |