English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
Writing to argv[0]
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2008-10-09 (15:43)
From: Savanni D'Gerinel <savanni@a...>
Subject: Re: [Caml-list] Writing to argv[0]
One possibility is setproctitle.  It appears to be non-standard, but  
maybe a bit more standard than overwriting argv[0].  I know it works  
on Linux, and I see a FreeBSD man page for it.

"The setproctitle() function is implicitly non-standard.  Other  
methods of
causing the ps(1) command line to change, including copying over the
argv[0] string are also implicitly non-portable.  It is preferable to  
an operating system supplied setproctitle() if present."

I do not know whether there is an OCaml function to do this, and it  
might actually be complicated because of the variable length argument  
list.  I have not written enough ocaml -> C bindings to have any idea  
how to handle that.


On Oct 9, 2008, at 10:31 AM, Basile STARYNKEVITCH wrote:

> Dave Benjamin wrote:
>> Hi,
>> Is there any way for an OCaml program to change its name in the  
>> process table? Assigning to Sys.argv.(0) has no effect.
> Write a C wrapper for that. And this trick seems Linux specific (it  
> has no sense in Posix) -maybe working on few other OSes.
> Regards.
> -- 
> Basile STARYNKEVITCH         http://starynkevitch.net/Basile/
> email: basile<at>starynkevitch<dot>net mobile: +33 6 8501 2359
> 8, rue de la Faiencerie, 92340 Bourg La Reine, France
> *** opinions {are only mines, sont seulement les miennes} ***
> _______________________________________________
> Caml-list mailing list. Subscription management:
> http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
> Archives: http://caml.inria.fr
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs