title: Mac OS X: Getting detailed process information (specifically its launch arguments) for arbitrary running applications using its PID
body: <p>I am trying to detect when particular applications are launched.</p>
  
  <p>Currently I am using <code>NSWorkspace</code>, registering for the "did launch application" notification. I also use the <code>runningApplications</code> method to get apps that are currently running when my app starts.</p>
  
  <p>For most apps, the name of the app bundle is enough. I have a plist of "known apps" that I cross check with the name of that passed in the notification.</p>
  
  <p>This works fine until you come across an app that acts as a proxy for launching another application using command line arguments.</p>
  
  <p>Example: The newly released Portal on the Mac doesn't have a dedicated app bundle. Steam can create a shortcut, which serves as nothing more than to launch the <code>hl2_osx</code> app with the <code>-game</code> argument and <code>portal</code> as it's parameter.</p>
  
  <p>Since more Source based games are heading to the Mac, I imagine they'll use the same method to launch, effectively running the <code>hl2_osx</code> app with the <code>-game</code> argument.</p>
  
  <p>Is there a nice way to get a list of the arguments (and their parameters) using a Cocoa API?</p>
  
  <p><code>NSProcessInfo</code> comes close, offering an `-arguments' method, but only provides information for its own process...</p>
  
  <p><code>NSRunningApplication</code> offers the ability to get information about arbitrary apps using a PID, but no command line args...</p>
  
  <p>Is there anything that fills the gap between the two?</p>
  
  <p>I'm trying not to go down the route of spawning an <code>NSTask</code> to run <code>ps -p [pid]</code> and parsing the output... I'd prefer something more high level.</p>