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=none autolearn=disabled version=3.1.3 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 38EC9BC69 for ; Fri, 14 Sep 2007 08:47:45 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAAAfL6UbAXQImn2dsb2JhbACOEgEBAQEHBAYHCBiXeA X-IronPort-AV: E=Sophos;i="4.20,253,1186351200"; d="scan'208";a="1181028" Received: from discorde.inria.fr ([192.93.2.38]) by mail2-smtp-roc.national.inria.fr with ESMTP; 14 Sep 2007 08:48:15 +0200 Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id l8E6lvrc024578 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Fri, 14 Sep 2007 08:47:58 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAAIPL6Uba1uFinmdsb2JhbACOEgEBAQEHBAYPGJd5 X-IronPort-AV: E=Sophos;i="4.20,253,1186351200"; d="scan'208";a="2690355" Received: from smtp.syd.people.net.au ([218.214.225.98]) by mail3-smtp-sop.national.inria.fr with SMTP; 14 Sep 2007 08:48:14 +0200 Received: (qmail 31662 invoked from network); 14 Sep 2007 06:48:22 -0000 Received: from unknown (HELO hendrix.mega-nerd.net) (218.214.64.136) by smtp.syd.people.net.au with SMTP; 14 Sep 2007 06:48:22 -0000 Received: from hendrix (hendrix [192.168.200.99]) by hendrix.mega-nerd.net (Postfix) with SMTP id 2990B30104 for ; Fri, 14 Sep 2007 16:48:11 +1000 (EST) Date: Fri, 14 Sep 2007 16:48:10 +1000 From: Erik de Castro Lopo To: caml-list@inria.fr Subject: Re: [Caml-list] Closing all open file descriptors Message-Id: <20070914164810.39a4dcda.mle+ocaml@mega-nerd.com> In-Reply-To: <46EA2BC8.7040508@ramenlabs.com> References: <20070914110403.f1ffe94b.mle+ocaml@mega-nerd.com> <46EA2BC8.7040508@ramenlabs.com> Reply-To: caml-list@inria.fr Organization: Erik Conspiracy Secret Labs X-Mailer: Sylpheed 2.3.1 (GTK+ 2.10.11; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Miltered: at discorde with ID 46EA2E9E.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; ocaml:01 descriptors:01 stdio:01 endline:01 syslog:01 ocaml:01 ubuntu:98 deceit:98 wrote:01 unix:01 unix:01 caml-list:01 benjamin:01 string:02 seems:03 Dave Benjamin wrote: > Did your program "daemonize" at all, then? Or did you use daemontools? Yes, it called Unix.fork and then in the child called Unix.setsid. Err, what's daemontools? > I can see how it might be annoying to try to make a daemon run on stdio > instead, and not being able to keep the file handles open... but it > seems like daemons could be written to work either way if designed with > some care. My program has passes around a logging function of type "string -> unit". If it not a daemon it uses print_endline for logging and if it is a daemon it uses a wrapper around syslog (via the debian/ubuntu libsyslog-ocaml-dev) package. > Yeah, the whole operation could be done in a C function too, and > probably wouldn't be much more code to write. My daemon is only tiny, but I'm, still glad its in Ocaml. Erik -- ----------------------------------------------------------------- Erik de Castro Lopo ----------------------------------------------------------------- "War is deceit." -- Islam's prophet Mohammed (Hadith 4:268)