S
Stevie
Very simply I'm sure, but how does one check whether a file is 'in use'
using perl?
Thanks a million
Stevie
using perl?
Thanks a million
Stevie
Stevie said:Very simply I'm sure, but how does one check whether a file is 'in use'
using perl?
Stevie said:Very simply I'm sure, but how does one check whether a file is 'in use'
using perl?
Thanks a million
Stevie
Stevie said:OK, Understood your points about portability but thats not an issue
here. I'm running linux and my main concern is to ensure the code
executes as fast as possible. The reason I'm checking for it being
locked is to make sure that it is not being written to by another
process.
Current code is:
system("lsof $file");
if ( $? == 0 ) {
print " success - not locked, exit status = $?\n";
} else {
print " failure - locked, exit status = $?\n";
}
This always returns failure with a exit status of 256. Any ideas why?
Would it be better/faster to try to open the file?
Any suggestions gratefully received.
Stevie
Stevie said:OK, Understood your points about portability but thats not an issue
here. I'm running linux and my main concern is to ensure the code
executes as fast as possible. The reason I'm checking for it being
locked is to make sure that it is not being written to by another
process.
Current code is:
system("lsof $file");
if ( $? == 0 ) {
print " success - not locked, exit status = $?\n";
} else {
print " failure - locked, exit status = $?\n";
}
This always returns failure with a exit status of 256. Any ideas why?
Would it be better/faster to try to open the file?
Any suggestions gratefully received.
Stevie
Would it be better/faster to try to open the file?
Any suggestions gratefully received.
OK, Understood your points about portability but thats not an issue
here. I'm running linux and my main concern is to ensure the code
executes as fast as possible.
The reason I'm checking for it being locked is to make sure that it is
not being written to by another process.
Current code is:
system("lsof $file");
if ( $? == 0 ) {
print " success - not locked, exit status = $?\n";
} else {
print " failure - locked, exit status = $?\n";
}
This always returns failure with a exit status of 256. Any ideas why?
Indeed. Also because it basically has to check for all processess, if
some hold a file descriptor opened on the wanted file. It amounts to
say that the system keeps track of which process has opened which
file, and that kind of info is fast to recover, but not vice versa, in
which case it's possible to recover the corresponding one, but one has
to lookup for it, and that's slow. Speaking of which I wondered
whether there exist a filesystem that *does* keep track of the reverse
info and provides means to recover it fast by means of a suitable
call.
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.