Can't make flock work as described... 
Author Message
 Can't make flock work as described...

 [courtesy cc of this posting sent to cited author via email]


:After reading about flock in the man-pages and "the Camelbook", I wrote a
:little test to try it out. Unfortunately, I can't make it work the way it's
:described, well, the way I interpret the descriptions anyway. What am I
:doing wrong?

You seen to thing that the flock(2) system call (or its various emulations)
interferes with the write(2) system call.  Nothing could be further from
the truth.  

Flocking files is like putting up a stop-and-go light at an intersection.
It works only if everyone using that intersection pays attention to
whether the light is red or green--or yellow in the case of a shared lock.
The red light doesn't stop traffic; it merely asks that traffic stop.
Someone who's desperate, ignorant, or rude will still go flying through
the intersection no matter what the light says.  Likewise, all that
flock blocks out is other flockers--not processes trying to do I/O.
Unless everyone is polite, accidents can (and will) happen.

Be polite.

--tom
--
This is the typical life of any Unix administrator. Most user/system problems
tend to read just like detective novels. Sometimes we win, sometimes we



Wed, 24 Jan 2001 03:00:00 GMT  
 Can't make flock work as described...
OK, so how should breakin.pl (in my example) implement this politeness?
In other words, please correct my example to make it work.

Politely, Johan E

<snip>

Quote:
>Likewise, all that
>flock blocks out is other flockers--not processes trying to do I/O.
>Unless everyone is polite, accidents can (and will) happen.

>Be polite.



Wed, 24 Jan 2001 03:00:00 GMT  
 Can't make flock work as described...
 [courtesy cc of this posting sent to cited author via email]


:OK, so how should breakin.pl (in my example) implement this politeness?
:In other words, please correct my example to make it work.

If you expect a program to honor flocks, you have to have
flock calls in that program.  Is that too obvious?  

(Not that you posted programs; I saw only libraries.)

--tom
--
    #define NULL 0           /* silly thing is, we don't even use this */
        --Larry Wall in perl.c from the v4.0 perl source code



Wed, 24 Jan 2001 03:00:00 GMT  
 Can't make flock work as described...
<snip>

Quote:
>If you expect a program to honor flocks, you have to have
>flock calls in that program.  Is that too obvious?

Maybe it is... -thank you very much, I got it working now. Much obliged.
:)

Quote:
>(Not that you posted programs; I saw only libraries.)

Speaking of politeness earlier, I can't help thinking that you seem to want
to pick on me for looking for more knowledge. I use the .pl extension
because that's what I've learnt to do, through for example the PERL5 HowTo
from Waite Group press. It would be nicer and politer of you to tell me what
extension to use, instead of talking in insinuations and riddles. I really
like Perl and am dedicated to learning it well. I want to learn, so I ask
questions. Is that so strange?

What extension would you like me to use?

/Johan E



Wed, 24 Jan 2001 03:00:00 GMT  
 Can't make flock work as described...
I did see the code that was posted and what Tom means (putting words in
his mouth) is that after one process has flocked the file a competing
process also has to call flock. An open and a subsequent write on an
flocked file will succeed but another flock will either block or return
with an error depending on the call. So cooperation between the
processes is necessary i.e. each needs to check the lock by calling
flock.
  David


Thu, 25 Jan 2001 03:00:00 GMT  
 Can't make flock work as described...

How about .plx? This was the suggested extention in Learning Perl on
Win32 Systems. As a result, .plx is what I use.

--
Jim Brewer
e-mailed courtesy copies are unappreciated, please refrain.



Thu, 25 Jan 2001 03:00:00 GMT  
 Can't make flock work as described...
i have noticed that several of the "high profile" users in this group appear
to be very short on patience and long on rudeness.

i keep reading very curt, offensive replies, which appear to be building up
the egos of the senders, and making the rest of us feel stupid.

this is why i HATE newgroups, and love compuserve.  there is such an
enormous lack of professionalism on the net.



Fri, 26 Jan 2001 03:00:00 GMT  
 Can't make flock work as described...

Todd> i have noticed that several of the "high profile" users in this
Todd> group appear to be very short on patience and long on rudeness.

I have noticed that several of the "new" users in this group appear to
be very short on their awareness of Usenet conventions and the
existing documentation, and long on expecting us to write their code
for them.

Todd> i keep reading very curt, offensive replies, which appear to be
Todd> building up the egos of the senders, and making the rest of us
Todd> feel stupid.

I keep reading very rambling, unclear posts, which appear to be
shifting the burden of the work from the poster to the respondant,
making the rest of us feel weary.

Todd> this is why i HATE newgroups, and love compuserve.  there is
Todd> such an enormous lack of professionalism on the net.

This is why I hate the fact that "Netscape" and "MSIE" have a "post"
button.  There is such an enormous lack of maturity on the net.

(Note: all strictly tongue-in-cheek... if you're offended, you
must be easily offended. :-)

--
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying

Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me



Fri, 26 Jan 2001 03:00:00 GMT  
 Can't make flock work as described...

Quote:

><snip>
> ... if you're offended, you
> must be easily offended. :-)

:]
-Sneex-
__________________________________________________________________
Bill Jones | FCCJ Webmaster | Life is a 'Do it yourself' thing...
             http://webmaster.fccj.org/cgi/mail?webmaster


Fri, 26 Jan 2001 03:00:00 GMT  
 Can't make flock work as described...

Quote:

> i have noticed that several of the "high profile" users in this group appear
> to be very short on patience and long on rudeness.

> i keep reading very curt, offensive replies, which appear to be building up
> the egos of the senders, and making the rest of us feel stupid.

Careful, now: you might hurt Tom C.'s feelings!

=g2



Fri, 26 Jan 2001 03:00:00 GMT  
 Can't make flock work as described...
Quote:


>Todd> i have noticed that several of the "high profile" users in this

[snip]

Quote:
>I have noticed that several of the "new" users in this group appear to

[snip]

Quote:
>(Note: all strictly tongue-in-cheek... if you're offended, you
>must be easily offended. :-)

Why toungue-in-cheek?  You phrased it very nicely and poiltely
(which is usual, for you - I have rarely, if ever, seen you go off
the deep end anyway).  However, what you said there is perfectly
valid and true.

If someone takes offence, why then, perhaps the shoe fits!



Sun, 28 Jan 2001 03:00:00 GMT  
 
 [ 11 post ] 

 Relevant Pages 

1. Making flock work over NFS in linux

2. Making sure 'perl -v' works

3. flock() doesn't work on Solaris

4. Making keyboard's keypad work with Tk

5. flock doesn't flock under perl/linux

6. how to use flock() on a machine, which dosn't support flock()

7. WANTED: Tim Cook's describe clone in perl

8. Making a portable program with flock()

9. Locking files -- 'flock'/'lockf/ question.

10. use Fcntl ':flock'

11. use Fcntl ':flock'

 

 
Powered by phpBB® Forum Software