Solved

How to get the number of processes

Posted on 1998-08-13
1
150 Views
Last Modified: 2010-04-01
Hi,
     I am writing a C++ program in a Solaris unix environment.
Now my question is how would I write a command in my program to know all the
processes that are running under my userid  presently?

Any help will be greatly appreciated.
Thanks
0
Comment
Question by:singhtaj
1 Comment
 
LVL 1

Accepted Solution

by:
slinky earned 100 total points
Comment Utility
Run a system call with the following UNIX command

ps -u <userid> | grep -v ps | wc -l

The grep ensures that you don't count the ps command as one of the processes.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now