From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=AWL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by yquem.inria.fr (Postfix) with ESMTP id 1AA98BC6C for ; Mon, 22 Oct 2007 21:58:17 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAAC+dHEfAXQInh2dsb2JhbACOVwEBAQgKKQ X-IronPort-AV: E=Sophos;i="4.21,313,1188770400"; d="scan'208";a="4977621" Received: from concorde.inria.fr ([192.93.2.39]) by mail3-smtp-sop.national.inria.fr with ESMTP; 22 Oct 2007 21:58:16 +0200 Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id l9MJwGFY000423 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Mon, 22 Oct 2007 21:58:16 +0200 X-IronPort-AV: E=Sophos;i="4.21,313,1188770400"; d="scan'208";a="3482077" Received: from smtpoutm.mac.com ([17.148.16.72]) by mail2-smtp-roc.national.inria.fr with ESMTP; 22 Oct 2007 21:58:14 +0200 Received: from mac.com (asmtp003-s [10.150.69.66]) by smtpoutm.mac.com (Xserve/smtpout009/MantshX 4.0) with ESMTP id l9MJwDln000145 for ; Mon, 22 Oct 2007 12:58:13 -0700 (PDT) Received: from [192.168.8.101] (c-24-218-151-219.hsd1.ma.comcast.net [24.218.151.219]) (authenticated bits=0) by mac.com (Xserve/asmtp003/MantshX 4.0) with ESMTP id l9MJw77e026000 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NO) for ; Mon, 22 Oct 2007 12:58:11 -0700 (PDT) Mime-Version: 1.0 (Apple Message framework v752.2) In-Reply-To: References: Content-Type: text/plain; charset=WINDOWS-1252; delsp=yes; format=flowed Message-Id: <971BB89E-D475-4414-B948-C9CE49B5F3DF@mac.com> Content-Transfer-Encoding: quoted-printable From: Gordon Henriksen Subject: Re: [Caml-list] How to monitor a specific file for changes Date: Mon, 22 Oct 2007 15:59:12 -0400 To: caml-list@inria.fr X-Mailer: Apple Mail (2.752.2) X-Miltered: at concorde with ID 471D00D8.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; ocaml:01 pointers:01 2007,:98 monitors:98 tiger:98 spotlight:98 wrote:01 abstract:01 caml-list:01 supported:02 library:03 bsd:04 msdn:05 interface:06 weak:06 On Oct 22, 2007, at 15:03, Orlin Grigorov wrote: > This time I've done my research, but still I cannot find a good =20 > answer. Basically, I need to make a little ocaml process, which =20 > runs in the background and monitors a specific file for changes. =20 > When a change occurs, I want it to back-up a copy of the version of =20= > the file at that moment. So, what I need is to set some signal =20 > or event, which will happen every time that file is changed. Orlin, If you wish to be cross-platform, you'll likely need to devise an =20 abstract interface to smooth over the variances between platforms. =20 You've plenty of Linux pointers already. On Windows, use FindFirstChangeNotification[1]. On Mac OS X and BSD, use kqueue[2]. kqueue was introduced in Tiger, =20 and is one of the supporting technologies for Spotlight. To support =20 Panther and earlier, you'll need to weak link[3] with kqueue. If =20 kqueue is unavailable or not supported on the filesystem in question, =20= you can fall back to polling modification times. Polling modification times is simple and highly portable; many Java =20 programs (for instance, Eclipse) support file monitoring using this =20 technique. It may be worth considering using it exclusively, at least =20= to get up and running. =97 Gordon [1] http://msdn2.microsoft.com/en-us/library/aa364417.aspx [2] http://developer.apple.com/documentation/Darwin/Reference/=20 ManPages/man2/kqueue.2.html [3] http://developer.apple.com/technotes/tn2002/tn2064.html