473,387 Members | 1,535 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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 4148
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: yawnmoth | last post by:
how can i determine what the maximum number of processes i should open with popen (or proc_open) is? i assume it'd depend on the hardware of the computer in question, but if that were teh case,...
5
by: Roger | last post by:
I would like to get a list of running processes on a remote machine. How is this possible via VB.Net? Is it possible? Can someone point me in the right direction. thanks, rog
0
by: Rusty Shackleford | last post by:
I am having trouble getting my ASP.Net applications and sessions to stay running. At first, I thought it was my lack of understanding of ASP.Net, or the fact that I am using Anonymous...
4
by: sneffe | last post by:
Hi, im writing a program to keep track of which programs is currently running. I would like to have the caption of running programs displayed in a textbox on my form. I cant seem to find an easy way...
5
by: Simon Hart | last post by:
Does anyone know the standard code access permission to be able to manipulate a process using the Process class? Thanks Simon.
6
by: dspfun | last post by:
I would like to analyze my running c-program. What I would like to know for example is the range of the entire address space of my running c-program (memory reserved for/by the running program),...
9
by: Tony | last post by:
Hi all, I have a DB2 8.2(fk14) running on Solaris 9 server. Once the DB2 working, I can see more than 30 DB2 processes(db2sysc) running at the same time. Is that normal? Thanks.
4
by: commander_coder | last post by:
Hello, I write a lot of CGI scripts, in Python of course. Now I need to convert some to long-running processes. I'm having trouble finding resources about the best practices to do that. ...
5
by: Jeff | last post by:
I need to run many processes from my application. and I am using the following enclosed in a for next loop: System.Diagnostics.Process runObj = new System.Diagnostics.Process();...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.