title: Setting process name on Mac OS X at runtime
body: <p>I'm trying to change my process' name as it appears in <code>ps</code> and <code>Activity Monitor</code> at runtime. I found several notes that there is no portable way to do this (which I don't care about).</p>
  
  <p>Here's what I tried. None of these approaches worked for me.</p>
  
  <ul>
  <li>Changing <code>argv[0]</code> (seems to be the way to go on some Unix systems)</li>
  <li>Calling <code>[[NSProcessInfo processInfo] setProcessName:@"someName"]</code></li>
  <li>Calling <code>setprogname</code> (calling <code>getprogname</code> returns the name I set, but that is irrelevant)</li>
  </ul>
  
  <p>I also read about a function called <code>setproctitle</code> which should be defined in <code>stdlib.h</code> if it is available, but it's not there.</p>
  
  <p>There must be a way to accomplish this because QTKitServer - the faceless decoder for QuickTime Player X - has its corresponding QuickTime Player's PID in its process name.</p>
  
  <p>Does anybody have a clue about how to accomplish this? I'd very much prefer a Core Foundation or POSIXy way over an Objective-C method to do this.</p>
  
  <p>Thanks,</p>
  
  <p>Marco</p>
  
  <p><strong>Edit:</strong> If it is in any way relevant, I'm using Mac OS X 10.6.5 and Xcode 3.2.5</p>