Lorenzo Pistone
Lorenzo Pistone

Reputation: 5188

get thread status, like top

What is the linux API to query the status of a thread, like the top -H command can do? I do not need portability, it just has to work on modern x86[_64] linux.

I do not want to only know if the thread is alive or terminated. I need to know if it's sleeping also.

Upvotes: 0

Views: 495

Answers (2)

alk
alk

Reputation: 70971

As far as I know top reads its information from /proc, on Linux at least.

Update: For top's sources you might like to read here: Procps - The /proc file system utilities

Upvotes: 1

ecatmur
ecatmur

Reputation: 157464

You want to use libproc, from procps ( http://procps.sourceforge.net/).

There isn't any API documentation online, but http://codingrelic.geekhold.com/2011/02/listing-processes-with-libproc.html is a pretty good introduction to using libproc.

Upvotes: 1

Related Questions