Finding thread info on Solaris

June 11, 2010

As part of a crusade to find bugs in a C++ program running on a Solaris system I needed to find out information about all the threads belonging to a certain process.

The program is written the way it is because you rarely need thread info about all threads running in a system but rather threads limited to a certain process. A different way to get this info is through the /proc file system but unfortunately (or fortunately ?!?) files in this Solaris file system usually have binary content as opposed to the textual content that one usually finds on a Linux system.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/perl -w
 
# Give this script the name of a process and it will show you thread
# infomation about your process...
 
 
use strict;
use diagnostics;
 
 
if(@ARGV<1) {
    die("usage myps.pl [process names...]");
}
 
 
for(my($p)=0;$p<@ARGV;$p++) {
    my($pname)=$ARGV[$p];
    print "showing diagnostics information for process $pname\n";
 
 
    # first lets find out the pid of the process
    my($pid)=`pgrep $pname`;
    chop($pid);
    print "The process id of the process is $pid\n";
 
 
    # now lets print all the thread info for that process...
    my(@lines)=`ps -eL`;
    for(my($i)=0;$i<@lines;$i++) {
        my($line)=$lines[$i];
        my(@fields)=split(" ",$line);
        if($fields[0] eq $pid) {
            print $line;
            #print(join('-',@fields));
        }
    }
}

tags: , , ,
posted in Technical by Mark Veltzer

Follow comments via the RSS Feed | Leave a comment | Trackback URL

2 Comments to "Finding thread info on Solaris"

  1. Birtefal wrote:

    Another intermediary that adds to this is that the acceptable pricing of generic Viagra does not sway its quality. Viagra is priceless as its manufacturers have to hold up the bring in of getting the medication researched upon, snap moolah in its moulding and marketing and later throw away heavily on post marketing reconnaissance to be intelligent about treatment of this soporific in the market.
    order cialis online

  2. Zidresav wrote:

    Another factor that adds to this is that the wise pricing of generic Viagra does not sham its quality. Viagra is up-market as its manufacturers include to hold up the fetch of getting the panacea researched upon, tender moolah in its casting and marketing and later expend heavily on notify marketing watch to be informed about reaction of this medicine in the market.
    order cialis online usa

Leave Your Comment

 
Powered by Wordpress and MySQL. Theme by Mark Veltzer derived from Shlomi Noachs openark theme