views:

245

answers:

4

I am looking for a command in Unix that returns the status of a process(active, dead, sleeping, waiting for another process, etc.)

is there any available?
A shell script maybe?

A: 

Playing with ps options doesn't give you what you need?

Rob Wells
A: 

Sorry, my unix-fu is beginner level. I'll have to check ps. Any website you can recommend?

lamcro
For Solaris 10, try http://docs.sun.com/app/docs/doc/816-5165or google: ps(1) site:docs.sun.com
tpgould
+2  A: 

in linux, something like ps -p somepid --no-headers -o state should work, alternately you can look for the info in proc with grep ^State: /proc/somepid/status

Brian Mitchell
+2  A: 

Try pflags <pid>, which will give you per-thread status information. Example:

root@weetbix # pflags $$
3384:   bash
        data model = _ILP32  flags = ORPHAN|MSACCT|MSFORK
 /1:    flags = ASLEEP  waitid(0x7,0x0,0xffbfefc0,0xf)
        sigmask = 0x00020000,0x00000000

Also check out the manpage for pflags to see other useful tools like pstack, pfiles, pargs etc.

TLS