[racket] Can raco exe assign a name other than "racket"?

From: Neil Van Dyke (neil at neilvandyke.org)
Date: Sat Mar 26 16:13:02 EDT 2011

Greg Hendershott wrote at 03/26/2011 12:14 PM:
> $ raco exe -o foo foo.rkt
> $ ./foo &
> $ ps  #shows it as "racket" not as "foo".
> $ top  #shows it as "racket" not as "foo".
>
> Is there way I can make it show up as "foo"?
>   

You can often do this in C on Unix variants by mutating the string 
buffers pointed to by "argv" argument as passed to the "main" function. 

To do this for executables created in the manner above, I suspect that 
someone would have to modify the C code for Racket, but I have not 
verified this.  (I started to look at the 5.0.2 code just now, and 
didn't immediately see an obvious way without modifying the C code, but 
I have to run to something now, so you might see a way if you read 
through the code.)

Use this feature with discretion, since the effect can be confusing to 
people trying to debug.  (Some daemons have been known to abuse this 
feature to show application-specific status, preventing you from seeing 
the original command line arguments.  A colleague once hacked an old 
Unix game to show up in the process table as "vi resume" on time-sharing 
systems, back when employers were more motivated to keep employees 
happy.)  And exercise the usual system programming caution, since you 
don't want to stomp on the wrong memory here, nor corrupt the info that 
"ps" and other tools will be looking at.

In the case of the original "raco exe" question, perhaps this is 
something that Racket should be changed to do by default?  I have no 
opinion on that.

-- 
http://www.neilvandyke.org/


Posted on the users mailing list.