Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 23 Nov 2003 10:35:44 +0000
From:      Matthew Seaman <m.seaman@infracaninophile.co.uk>
To:        "Cordula's Web" <cpghost@cordula.ws>
Cc:        questions@freebsd.org
Subject:   Re: Monitoring a file?
Message-ID:  <20031123103544.GD9494@happy-idiot-talk.infracaninophile.co.uk>
In-Reply-To: <200311231017.hANAHvpd097677@fw.farid-hajji.net>
References:  <200311222258.hAMMwApd092388@fw.farid-hajji.net> <16320.5175.69241.145102@jerusalem.litteratus.org> <200311231017.hANAHvpd097677@fw.farid-hajji.net>

next in thread | previous in thread | raw e-mail | index | archive | help

--P+33d92oIH25kiaB
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Sun, Nov 23, 2003 at 11:17:57AM +0100, Cordula's Web wrote:
> > >  A file, let's say, /path/to/a/file, is being modified by
> > >  an unknown process P(u) at random times. Unfortunately,
> > >  the name of the program ran by P(u) is unknown.
> >=20
> > 	Have you tried moving the file elsewhere and seeing if anyone
> > complains about the absence?
>=20
> No, P(u) obviously fails silently. There's nothing recorded
> by syslog, no messages on the console, and no core dumps...
>=20
> > 	Or writing a program that locks the file?
>=20
> That was a good idea. However, P(u) didn't seem to take a lock.
> Advisory locks are just that: if P(u) doesn't lock the file,
> existing locks don't matter at all. Do we have mandatory locks
> in FreeBSD?

Not a lock as such, but:

    # chflags schg /path/to/a/file

should achieve the effect you desire.  Although this will cause any
write on the file to just fail, rather than causing P(u) to block
waiting for a lock.  You could try replacing /path/to/a/file with a
fifo (see mkfifo(1)), and maybe hang another process on the other end
of the fifo which can run ps(1) or fstat(1) when a write is detected.

	Cheers,

	Matthew

--=20
Dr Matthew J Seaman MA, D.Phil.                       26 The Paddocks
                                                      Savill Way
PGP: http://www.infracaninophile.co.uk/pgpkey         Marlow
Tel: +44 1628 476614                                  Bucks., SL7 1TH UK

--P+33d92oIH25kiaB
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (FreeBSD)

iD8DBQE/wI2AdtESqEQa7a0RAgtWAJ40lwDH9UydRUmtw8UGTwfsMoKpVACff9Nd
OQJqWMhVSjyd9Ufsf3049sw=
=m0x5
-----END PGP SIGNATURE-----

--P+33d92oIH25kiaB--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20031123103544.GD9494>