from small one page howto to huge articles all in one place
 

search text in:





Poll
Which kernel version do you use?





poll results

Last additions:
using iotop to find disk usage hogs

using iotop to find disk usage hogs

words:

887

views:

195651

userrating:

average rating: 1.7 (102 votes) (1=very good 6=terrible)


May 25th. 2007:
Words

486

Views

252057

why adblockers are bad


Workaround and fixes for the current Core Dump Handling vulnerability affected kernels

Workaround and fixes for the current Core Dump Handling vulnerability affected kernels

words:

161

views:

140922

userrating:

average rating: 1.4 (42 votes) (1=very good 6=terrible)


April, 26th. 2006:

Druckversion
You are here: manpages





MAILOCK

Section: Linux Programmer's Manual (3)
Updated: 28 March 2001
Index Return to Main Contents
 

NAME

maillock, mailunlock, touchlock - manage mailbox lockfiles  

SYNOPSIS

#include <maillock.h>

cc [ flag ... ] file ... -llockfile [ library ]

int maillock( const char *user, int retrycnt );
void mailunlock( void );
void touchlock( void );  

DESCRIPTION

The maillock function tries to create a lockfile for the users mailbox in an NFS-safe (or resistant) way. The algorithm is documented in lockfile_create(3).

The mailbox is typically located in /var/mail. The name of the lockfile then becomes /var/mail/USERNAME.lock. If the environment variable $MAIL is set, and it ends with the same username as the username passed to maillock(), then that file is taken as the mailbox to lock instead.

There is no good way to see if a lockfile is stale. Therefore if the lockfile is older then 5 minutes, it will be removed. That is why the touchlock function is provided: while holding the lock, it needs to be refreshed regulary (every minute or so) by calling touchlock () .

Finally the mailunlock function removes the lockfile.

 

RETURN VALUES

maillock returns one of the following status codes:

   #define L_SUCCESS   0    /* Lockfile created                     */
   #define L_NAMELEN   1    /* Recipient name too long (> 13 chars) */
   #define L_TMPLOCK   2    /* Error creating tmp lockfile          */
   #define L_TMPWRITE  3    /* Can't write pid int tmp lockfile     */
   #define L_MAXTRYS   4    /* Failed after max. number of attempts */
   #define L_ERROR     5    /* Unknown error; check errno           */

 

NOTES

These functions are not thread safe. If you need thread safe functions, or you need to lock other mailbox (like) files that are not in the standard location, use lockfile_create(3) instead.

These functions call lockfile_create(3) to do the work. That function might spawn a set group-id executable to do the actual locking if the current process doesn't have enough priviliges.

There are some issues with flushing the kernels attribute cache if you are using NFS - see the lockfile_create(3) manpage.  

FILES

/var/mail/user.lock,
/usr/lib/liblockfile.so.1

 

AUTHOR

Miquel van Smoorenburg <miquels@cistron.nl>

 

SEE ALSO

lockfile_create(3), lockfile_touch (3), lockfile_remove(3)


 

Index

NAME
SYNOPSIS
DESCRIPTION
RETURN VALUES
NOTES
FILES
AUTHOR
SEE ALSO





Support us on Content Nation
rdf newsfeed | rss newsfeed | Atom newsfeed
- Powered by LeopardCMS - Running on Gentoo -
Copyright 2004-2020 Sascha Nitsch Unternehmensberatung GmbH
Valid XHTML1.1 : Valid CSS : buttonmaker
- Level Triple-A Conformance to Web Content Accessibility Guidelines 1.0 -
- Copyright and legal notices -
Time to create this page: 10.7 ms