Page 1 of 1

ReadFile() never exit on locked files

Posted: Sat Sep 12, 2009 6:43 am
by cy-5
It seems that ReadFile() never return when the file we want to open is locked. I'm using PB4.31(x86) version on Ubuntu 9.04.
I'll explain. I'm writing an application which read files and add them to another file. I've tried it on my "Desktop" directory and it works fine. But once I try it on my "/home/user1/" directory(where user1 is your login name) for some files it works and some it don't. Especially that file: "/home/user1/.synfig/fifo". I've tried also with that minimal code and believe me or not even in debug if you press F8 on the ReadFile() line it never get to the "IF". I've read a bit about locks mechanism on linux and I've known that there is 3 different locks types. See http://www.unixguide.net/unix/programming/2.5.shtml and if an application don't use the same lock types as the other one it can delete/read the file even if locked by another application. I don't know what is the type of lock used by the applicaton wich open that file. But, it think it would be better to make sure ReadFile() don't block at all and just return 0 whatever the lock type used. BTW here is the code.:

Code: Select all

Global GintIDFile.l = ReadFile(#PB_Any, "/home/user1/.synfig/fifo")

;It never reach the IF when the file is locked.
If GintIDFile = 0
  Debug "Failed"
Else
  Debug "Succeeded"
EndIf

Re: ReadFile() never exit on locked files

Posted: Sat Sep 12, 2009 9:19 am
by Little John
Maybe it helps to better understand the situation, when we know the attributes of the concerning file.

Code: Select all

Debug GetFileAttributes("/home/user1/.synfig/fifo")
Regards, Little John

Re: ReadFile() never exit on locked files

Posted: Sat Sep 12, 2009 2:34 pm
by cy-5
Permission on the file are, when seen from the file properties:
-Owner: Read and Write
-Group: No access(for each groups)
-Others: No access
-Not set has been executable file.

Also using GetFileAttributes() it gave: 448.

Hope this will be helpful.

Re: ReadFile() never exit on locked files

Posted: Mon Aug 13, 2012 9:26 pm
by Fred
Unfortunately, we can't reproduce the problem without a sample which actually shows the issue.