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=1.0 required=5.0 tests=AWL,SPF_FAIL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by yquem.inria.fr (Postfix) with ESMTP id 0574DBC69 for ; Mon, 22 Oct 2007 21:11:01 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAAKOSHEfAXQImh2dsb2JhbACOVwEBAQgKKQ X-IronPort-AV: E=Sophos;i="4.21,312,1188770400"; d="scan'208";a="3480328" Received: from discorde.inria.fr ([192.93.2.38]) by mail2-smtp-roc.national.inria.fr with ESMTP; 22 Oct 2007 21:11:00 +0200 Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id l9MJAvel030731 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Mon, 22 Oct 2007 21:11:00 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAABuTHEdQW+UCh2dsb2JhbACOVwEBAQgKKQ X-IronPort-AV: E=Sophos;i="4.21,312,1188770400"; d="scan'208";a="3498340" Received: from main.gmane.org (HELO ciao.gmane.org) ([80.91.229.2]) by mail1-smtp-roc.national.inria.fr with ESMTP; 22 Oct 2007 21:11:00 +0200 Received: from list by ciao.gmane.org with local (Exim 4.43) id 1Ik2fi-0001AC-AO for caml-list@inria.fr; Mon, 22 Oct 2007 19:10:42 +0000 Received: from ks300734.kimsufi.com ([91.121.65.225]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 22 Oct 2007 19:10:42 +0000 Received: from sylvain by ks300734.kimsufi.com with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 22 Oct 2007 19:10:42 +0000 X-Injected-Via-Gmane: http://gmane.org/ To: caml-list@inria.fr From: Sylvain Le Gall Subject: Re: How to monitor a specific file for changes Date: Mon, 22 Oct 2007 19:09:57 +0000 (UTC) Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: ks300734.kimsufi.com User-Agent: slrn/0.9.8.1pl2 (Debian) Sender: news X-Miltered: at discorde with ID 471CF5C1.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; le-gall:01 ocaml:01 descriptors:01 ocaml:01 macos:01 2007,:98 monitors:98 wrote:01 functions:01 exists:05 linux:07 linux:07 describe:07 background:91 solaris:08 On 22-10-2007, Orlin Grigorov wrote: > This time I've done my research, but still I cannot find a good answer. > Basically, I need to make a little ocaml process, which runs in the > background and monitors a specific file for changes. When a change occurs, > I want it to back-up a copy of the version of the file at that moment. > So, what I need is to set some signal or event, which will happen every time > that file is changed. > > Can you guys help me do it? > The thing you describe should be handled at OS level (at least this is kind of notification are bound to OS). This means, you don't have high level functions that are multi-OS. If you use linux 2.6, take a look at ocaml-inotify, which helps you to wait for specific event on some file descriptors (also work for directories): http://tab.snarc.org/projects/ocaml_inotify/ If you use older linux version, solaris, macos or windows, i have no answer (but i am sure this kind of things already exists). Regards, Sylvain Le Gall