Hello everyone, and thanks for the help. I guess I should make clear the
purpose of the code I sent before.
It seems that the flock wouldn´t work (would not give an exclusive lock) on
the evironment I am working, I´ve tried everything. So I´ve tried to make
another program to replace it, the idea is this:
Let file1 be the file I´ll be reading and writing.
Let filelock be a file on non zero size.
So, before atempting to open file1 I´ll call my_lock_function() which
basicly checks to see if filelock has zero size or not (it has zero size
when it is opened with a +> or >). If its size is zero it will wait for 0.1
seconds and try again. If its size is nonzero the it opens filelock with a
+> or >. Now I do whatever operation I want with file1 and then call
my_unlock_function() which only closes the filelock. (Which should end up
with a nonzero size since I haven´t writen/read nothing to the file). This
last part was where I was having problems, and the reason for posting "Need
help with mysterious code".
So if anyone colud help me with this alternative flock function I would be
Oi! Você quer um iG-mail gratuito?
Então clique aqui: http://www.ig.com.br/paginas/assineigmail.html