title: ps display thread name
body: <p>Is there a way for <code>ps</code> (or similar tool) to display the pthread's name?
  I wrote the following simple program:</p>
  
  <pre><code>// th_name.c
  #include &lt;stdio.h&gt;
  #include &lt;pthread.h&gt;
  
  void * f1() {
      printf("f1 : Starting sleep\n");
      sleep(30);
      printf("f1 : Done sleep\n");
  }
  
  int main() {
  
      pthread_t  f1_thread;
      pthread_create(&amp;f1_thread, NULL, f1, NULL);
      pthread_setname_np(f1_thread, "f1_thread");
  
      printf("Main : Starting sleep\n");
      sleep(40);
      printf("Main : Done sleep\n");
      return 0;
  
  }
  </code></pre>
  
  <p>Is there a command/utility (like <code>ps</code>) that I can use to display the threads for the above program, along with their name.</p>
  
  <pre><code>$ /tmp/th_name &gt; /dev/null &amp;
  [3] 2055
  $ ps -eLf | egrep "th_name|UID"
  UID        PID  PPID   LWP  C NLWP STIME TTY          TIME CMD
  aal      31088 29342 31088  0    2 10:01 pts/4    00:00:00 /tmp/th_name
  aal      31088 29342 31089  0    2 10:01 pts/4    00:00:00 /tmp/th_name
  aal      31095 29342 31095  0    1 10:01 pts/4    00:00:00 egrep th_name|UID
  </code></pre>
  
  <p>I am running my program on Ubuntu 12.10.</p>