Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^2: Exclusive open for append

by tmoertel (Chaplain)
on Nov 18, 2005 at 18:53 UTC ( #509900=note: print w/replies, xml ) Need Help??


in reply to Re: Exclusive open for append
in thread Exclusive open for append

Both programs will have the file open for append. If both programs write to them, there's no garantee you end up with something that isn't garbage...

On sane Unix-like systems, there is a guarantee: you won't get garbage, regardless of the size of your writes. [1] If the log file is opened in append mode and each entry is committed as a single write (system call), Unix file semantics guarantee that the entries will be appended to the file atomically. (For more information see Re^3: Looking for a simple multiprocess-enabled logging module, which quotes the relevant bits of the Single Unix Specification.)

See also "All I want to do is append a small amount of text to the end of a file. Do I still have to use locking?" from perlfaq5.

Cheers,
Tom

[1] Provided that your log file resides on a filesystem that supports Unix semantics. Network-mounted filesystems often fall short.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://509900]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (6)
As of 2022-12-04 18:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?