On Mon, 19 Oct 1998, Glynn Clements wrote:

-> If i'm playing round with user's mailboxes, do i need to somehow lock
-> them?
-
-Yes.
-
-When manipulating mail spools, you should generally use both a
-lockfile and fcntl().
-
-To create a lockfile, create a file in the spool directory, link() it
-to <username>.lock, and unlink() the original. This is the only method 
-which is reliable over NFS.

so what i do is:

make some file in the spool dir.(using mktemp() or similar?)
link that file to <name_of_mail_spool>.lock
[do various nasty things to the mail spool :) ]
unlink the .lock file
delete the temp file

this right? the lock file doesn't need to contain any data does it? it's
just there as a marker for other things to check the existance of?

What happens if some other program (sendmail, procmail etc) tries to
fiddle with the locked mail spool, do they just hang around waiting? or is the
mail queued and it tried again later?

-- 
+++ Divide By Cucumber Error, Please Re-Install Universe And Reboot +++
[EMAIL PROTECTED]                    http://x-map.home.ml.org

Reply via email to