title: How to get PID of current rake task?
body: <p>I'm putting in a reaper line into a rake task to kill some additionally spawned ruby tasks as they somehow creep up on occasion.</p>
  
  <pre><code>system "ps aux | grep 'namespace:taskname' | grep ruby | grep -v grep | awk '{print $2}' | xargs kill -9; echo 'Reaped old namespace:taskname processes.'"
  </code></pre>
  
  <p>I'd like to add <code>grep -v $PID_OF_CURRENT_TASK</code> in that just to be sure I don't kill the current task that's running as well.</p>
  
  <p>How do I get that PID?</p>