caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Jason Noakes <jjnoakes@gmail.com>
To: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Writing to argv[0]
Date: Fri, 10 Oct 2008 14:48:16 -0400 (EDT)	[thread overview]
Message-ID: <1944.69.121.99.207.1223664496.squirrel@greatnorthern.org> (raw)
In-Reply-To: <48EF57F0.6000203@ramenlabs.com>

On Fri, October 10, 2008 9:26 am, Dave Benjamin wrote:
> 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

Just be careful with that. You are copying over memory and you also aren't
doing any bounds checking. A long enough "Proctitle.setproctitle" argument
will corrupt your process.

-JJ

--

<<  Jason J. Noakes  >>



  reply	other threads:[~2008-10-10 18:49 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-09 15:26 Dave Benjamin
2008-10-09 15:31 ` [Caml-list] " Basile STARYNKEVITCH
2008-10-09 15:43   ` Savanni D'Gerinel
2008-10-10  4:58     ` Dave Benjamin
2008-10-10  4:53   ` Dave Benjamin
2008-10-10 13:26     ` Dave Benjamin
2008-10-10 18:48       ` Jason Noakes [this message]
2008-10-10 20:11         ` Dave Benjamin
2008-10-10 15:11   ` Richard Jones
2008-10-10 16:33     ` Dave Benjamin
2008-10-10 16:59       ` Richard Jones
2008-10-10 20:19         ` Dave Benjamin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1944.69.121.99.207.1223664496.squirrel@greatnorthern.org \
    --to=jjnoakes@gmail.com \
    --cc=caml-list@yquem.inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).