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 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by yquem.inria.fr (Postfix) with ESMTP id 05B27BB84 for ; Fri, 10 Oct 2008 15:27:29 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApoEAIv07kjOe3NG/2dsb2JhbAC+C4Fs X-IronPort-AV: E=Sophos;i="4.33,389,1220220000"; d="scan'208";a="18548445" Received: from spoomusic.com ([206.123.115.70]) by mail1-smtp-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-SHA; 10 Oct 2008 15:27:28 +0200 Received: (qmail 5157 invoked by uid 89); 10 Oct 2008 13:27:26 -0000 Received: from unknown (HELO ?192.168.1.99?) (98.165.129.233) by 0 with ESMTPS (DHE-RSA-AES256-SHA encrypted); 10 Oct 2008 13:27:26 -0000 Message-ID: <48EF57F0.6000203@ramenlabs.com> Date: Fri, 10 Oct 2008 06:26:08 -0700 From: Dave Benjamin User-Agent: Mozilla-Thunderbird 2.0.0.16 (X11/20080724) MIME-Version: 1.0 To: Basile STARYNKEVITCH Cc: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Writing to argv[0] References: <48EE22B0.3090404@ramenlabs.com> <48EE23BF.3080300@starynkevitch.net> <48EEDFE5.8080706@ramenlabs.com> In-Reply-To: <48EEDFE5.8080706@ramenlabs.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Spam: no; 0.00; argv:01 basile:01 argv:01 gnu's:01 invocation:01 ocaml:01 idl:01 extern:01 invocation:01 endline:01 acb:98 003:98 char:01 char:01 wrote:01 Dave Benjamin wrote: > Basile STARYNKEVITCH wrote: >> Write a C wrapper for that. And this trick seems Linux specific (it >> has no sense in Posix) -maybe working on few other OSes. > > It doesn't seem like it's possible, even if I drop to C. Writing to > "caml_exe_name" does nothing, and "caml_main_argv" is declared static. Just as I was about to give up, I found this thread, which alerted me to GNU's "program_invocation_name" global: http://groups.google.com/group/comp.unix.programmer/browse_thread/thread/99acb4dff3707e56/003e46ff836f5d9e So, I finally got it to work in OCaml. This is GNU/Linux only, most likely. proctitle.idl: quote(c, "extern char * program_invocation_name;"); [string] char * getproctitle(void) quote(call, "_res = program_invocation_name;"); void setproctitle([string] char * proctitle) quote(call, "strcpy(program_invocation_name, proctitle);"); test.ml: let () = Proctitle.setproctitle "testing setproctitle"; print_endline (Proctitle.getproctitle ()); Unix.sleep 10