On Tue, Mar 27, 2001 at 03:05:07PM -0800, suse@rhugga.org wrote:
I have a need to obtain an exclusive lock on the shadow, group, and passwd files so that any process trying to modify these files will be blocked/denied until the lock is removed. I am not extremelly familiar with SuSE internals and etc.. I want to temporarily lock these files from either a perl of C program, preferably perl. It would take me many lines to explain line, but I simply need to lock these files so that no other process may modify them. (This lock would be held for a very short amount of time
, but the process obtaining this lock is no where near atomic) These are clinical systems reponsisble for monitoring life support equipment among other things, so a 'jerry-rig' approach will not suffice. I need a 100%, rock solid way of this locking this file. [in future, could you please limit your line lengths to about 75 characters? Thanks.] I'm enclosing two programs - one in C, and one in PERL that do what you want. -- David Smith Tel: +44 (0)1454 462380 (direct) STMicroelectronics Fax: +44 (0)1454 617910 1000 Aztec West TINA (ST only): (065) 2380 Almondsbury Home: 01454 616963 BRISTOL Mobile: 07932 642724 BS32 4SQ Work Email: Dave.Smith@st.com Home Email: David.Smith@ds-electronics.co.uk