ReadFile() never exit on locked files

Just starting out? Need help? Post your questions and find answers here.
cy-5
User
User
Posts: 10
Joined: Thu Jun 19, 2008 6:08 pm
Location: Canada

ReadFile() never exit on locked files

Post 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
Little John
Addict
Addict
Posts: 4812
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: ReadFile() never exit on locked files

Post 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
cy-5
User
User
Posts: 10
Joined: Thu Jun 19, 2008 6:08 pm
Location: Canada

Re: ReadFile() never exit on locked files

Post 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.
Fred
Administrator
Administrator
Posts: 18384
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: ReadFile() never exit on locked files

Post by Fred »

Unfortunately, we can't reproduce the problem without a sample which actually shows the issue.
Post Reply