Browse thread
Writing to argv[0]
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: | 2008-10-10 (18:49) |
From: | Jason Noakes <jjnoakes@g...> |
Subject: | Re: [Caml-list] Writing to argv[0] |
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 >>