From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id CF1CEBBC4 for ; Fri, 20 Jan 2006 17:49:29 +0100 (CET) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id k0KGnTf3011099 for ; Fri, 20 Jan 2006 17:49:29 +0100 Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id RAA31761 for ; Fri, 20 Jan 2006 17:49:28 +0100 (MET) Received: from mail.davidb.org (mail.davidb.org [66.93.32.219]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id k0KGnQwR005834 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Fri, 20 Jan 2006 17:49:27 +0100 Received: from davidb by mail.davidb.org with local (Exim 4.54 #1 (Debian)) id 1EzzRq-000469-CE; Fri, 20 Jan 2006 08:49:14 -0800 Date: Fri, 20 Jan 2006 08:49:14 -0800 From: David Brown To: skaller Cc: Richard Jones , caml-list@inria.fr Subject: Re: [Caml-list] toplevel with pre-installed printers Message-ID: <20060120164914.GA15521@old.davidb.org> References: <43CFBE3E.1090808@andrej.com> <43CFC776.3060801@andrej.com> <20060119174907.GA309@furbychan.cocan.org> <20060119191259.GB12416@localhost> <20060119201847.GA28585@furbychan.cocan.org> <1137723843.8822.139.camel@rosella> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1137723843.8822.139.camel@rosella> User-Agent: Mutt/1.5.11 X-Miltered: at nez-perce with ID 43D11499.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at concorde with ID 43D11496.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 caml-list:01 toplevel:01 argv:01 argv:01 stdio:01 argc:01 char:01 printf:01 gcc:01 unix:01 wrote:01 invoke:01 bin:01 int:01 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.3 On Fri, Jan 20, 2006 at 01:24:03PM +1100, skaller wrote: > You simply look at argv[0] which on some Unix systems > is the full path name of the invoked executable. Actually, argv[0] is almost never a full path. It is the path used to invoke the executable. So, if the program is in the user's path, then it will just be the filename, with no path information. In order to find itself, a program has to search for argv[0] in $PATH. If you don't believe me, try it: hello.c: #include int main (int argc, char **argv) { printf ("Program name: %s\n", argv[0]); } % gcc -o ~/bin/hello hello.c % hello Program name: hello Dave