Determining source of processes

Determining source of processes

Post by James Bening » Thu, 15 Jul 1999 04:00:00



Hi,
I've been programming C/C++ for a long time, but I'm new
to Unix programming.  The program I'm currently trying to
write requires a function to find all the processes currently
running whose executables are in a certain directory

Is there a simple library function I can use to determine this?

Thanks in advance,
James Beninger

   -**** Posted from RemarQ, http://www.remarq.com/?b ****-
 Real Discussions for Real People

 
 
 

Determining source of processes

Post by George MacDonal » Sun, 25 Jul 1999 04:00:00



> Hi,
> I've been programming C/C++ for a long time, but I'm new
> to Unix programming.  The program I'm currently trying to
> write requires a function to find all the processes currently
> running whose executables are in a certain directory

> Is there a simple library function I can use to determine this?

On Linux you can look at /proc/*/cwd

--
We stand on the shoulders of those giants who coded before.
Build a good layer, stand strong, and prepare for the next wave.
Guide those who come after you, give them your shoulder, lend them your code.


 
 
 

Determining source of processes

Post by Remco Treffkor » Sun, 25 Jul 1999 04:00:00




> > Hi,
> > I've been programming C/C++ for a long time, but I'm new
> > to Unix programming.  The program I'm currently trying to
> > write requires a function to find all the processes currently
> > running whose executables are in a certain directory

> > Is there a simple library function I can use to determine this?

> On Linux you can look at /proc/*/cwd

This gives you the cwd of a process, not where the binary resides.
Answer to the original question:

  It can not be done in a portable way.

BTW: This is a FAQ.

 
 
 

Determining source of processes

Post by Marc Lefran » Tue, 27 Jul 1999 04:00:00




> > Hi,
> > I've been programming C/C++ for a long time, but I'm new
> > to Unix programming.  The program I'm currently trying to
> > write requires a function to find all the processes currently
> > running whose executables are in a certain directory

> > Is there a simple library function I can use to determine this?

> On Linux you can look at /proc/*/cwd

Shouldn't that be /proc/*/exe ? He is interested in the location of
the excutable, not the current working directory.

--
Marc Lefranc
Laboratoire de Physique des Lasers, Atomes, Molcules
Universit des Sciences et Technologies de Lille

 
 
 

1. How to determine a process ID of a child process?

Hi Folks,

I have a perl script that runs an executable program(my_merger), there
is no error and I have what is expected. But, sometimes my_merger does
not exit smoothly or the process stays active in ps. my_merger is
eating up cpu resources that I have to kill manually. I cannot just
look at the program name because there are lots of instances of this
script.

To monitor, I am using top command and if there is a my_merger process
I kill it manually before crushing my system. Usually this my_merger
does not stay for long in ps. How can I determine the process ID for
me to make additional checking within the script to make sure that
my_merger was stopped gracefully. I cannot use '&' at the end of the
command because I need the return value.

#
sub my_proc {
   $retVal = `my_merger`;
   if ($?) {
   ...
   }

In advance, I am thankful to the one who can help me with this. It
will ease my burden to wake-up early morning just to monitor cpu
resources and killing the process.

Thanks,
IO

2. Separate cgi-bins with multiple Virtual Hosting by IP - How to do it?

3. Determining process ID from process name

4. 2.0 'make zImage' problems...

5. Quick way of determining processor MHz frequency -> Linux kernel sources?

6. KDE theme to gtk

7. How can sourced script determine own name?

8. UFS , SVR4, and inodes limits

9. How to determine source ip address

10. How do I determine source of my login?

11. How can sourced script determine own name?

12. use ps to determine the percentage of time a process is using a CPU