PLEX86  x86- Virtual Machine (VM) Program
 Plex86  |  CVS  |  Mailing List  |  Download  |  Linux  |  Newsgroups

How to detect locked files 3445


Your Ad Here

Your Ad Here

On Sat, 23 Apr 2005 22:02:46 GMT, Mackan staggered into the Black Sun and said:

"lsof $FILENAME" returns 1 in $? if $FILENAME has not been opened or does not exist, 0 in $? if the file is open. The text lsof returns will tell you which process has the file open and various details; check the man page and try it out yourself for more information.

There's probably a more efficient way to do this with fopen(), fileno(), and fcntl(fd,FGETLK,struck lock *mylock), buttuming the FTP server places a write lock on the files it's writing.

Er... FTP servers may not lock the files they're writing to. If they place an exclusive write lock on a file with fcntl(), that doesn't prevent another process from moving the file to another directory. Remember, moving-renaming files doesn't change the files themselves, but the directory the file is in (and the directory the file's being moved to, if you're moving a file.)

Not really relevant here; lsof works the same on ReiserFS as it does on ext23. HTH,

-- Matt GThere is no Darkness in Eternity-But only Light too dim for us to see Brainbench MVP for Linux Admin mail: TRAP + SPAN don't belong

How to detect locked files 3446
On Sun, 24 Apr 2005 01:08:38 GMT, Mackan staggered into the Black Sun and said: If you move it before the FTP server has finished writing, yeah, it might not be complete. Depends on how...



Your Ad Here

List | Previous | Next

How to detect locked files 3446

Linux groups from Newsgroups

The #1 Usenet Provider on the Internet

problems starting x