470,821 Members | 2,104 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,821 developers. It's quick & easy.

Get number of running processes

Hi,

I am looking for an easy way to find the total number of running
processes on a given machine in a C program. Currently I am doing
this:

system("ps -e | wc -l > count.txt");

then reading the number back into the program from the text file. I
was wondering if there was a function call that would do this (ie. int
count = get_process_count()) rather than perform this hackish
workaround.

Thanks for any help!
- Chris

Apr 29 '06 #1
2 3907
ch********@gmail.com opined:
Hi,

I am looking for an easy way to find the total number of running
processes on a given machine in a C program. Currently I am doing
this:

system("ps -e | wc -l > count.txt");

then reading the number back into the program from the text file. I
was wondering if there was a function call that would do this (ie.
int count = get_process_count()) rather than perform this hackish
workaround.


In standard C no, there isn't. Your implementation, or some system
specific library may well provide one. You seem to be running a *nixy
system, so comp.unix.programmer or similar may be the place to ask.

--
One does not thank logic.
-- Sarek, "Journey to Babel", stardate 3842.4

<http://clc-wiki.net/wiki/Introduction_to_comp.lang.c>

Apr 29 '06 #2
Thanks for the redirection.

Apr 29 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by yawnmoth | last post: by
reply views Thread by Rusty Shackleford | last post: by
4 posts views Thread by sneffe | last post: by
6 posts views Thread by dspfun | last post: by
4 posts views Thread by commander_coder | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.