comp.lang.ada
 help / color / mirror / Atom feed
From: cgreen@yosemite.atc.com (Christopher Green)
Subject: Re: How to query active processes from Ada
Date: 1997/01/03
Date: 1997-01-03T00:00:00+00:00	[thread overview]
Message-ID: <5ajroq$51l@newshub.atmnet.net> (raw)
In-Reply-To: 5aj97p$a9m@news.spar.ca


In article <5aj97p$a9m@news.spar.ca>, James d'Eon <james.deon@prior.ca> wrote:
>Hi,
>  I have a situation where I am trying to determine if a process is active. I 
>do know the process ID. This is pretty simple from the command line by using 
>the 'ps' command, but I have not been successful yet in implementing this in 
>Ada. Has anyone out there tried this, or have any ideas to point me in the 
>right direction? 
>
>Thanks,
>  James

This is system-dependent, but there is a solution that will work for any host
(most UNIX System V hosts) that has the /proc filesystem.  Every process on
such a host has a file named /proc/nnnnn, where nnnnn is the process ID.

If you have POSIX bindings, the function POSIX_Files.Is_File will return TRUE
if there is a file of the given name.  This is the best way; it will work
even if you are not the superuser.

If you do not, try opening the file /proc/nnnnn, where nnnnn is the process ID.
This will work only if you have the same user ID as the process you are testing,
or if you are the superuser.

If you do not have a /proc filesystem, there are still host-dependent ways to
check up on a process, but they are complex and involve reading kernel memory.
Discussion of these ways is beyond the scope of this post; if it is important
to you, get the source code for "top", or ask on comp.unix.programmer.

Chris Green                                  Email cgreen@atc.com
Advanced Technology Center                   Phone (714) 583-9119
22982 Mill Creek Drive                                   ext. 220
Laguna Hills, CA 92653                       Fax   (714) 583-9213




  parent reply	other threads:[~1997-01-03  0:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-01-03  0:00 How to query active processes from Ada James d'Eon
1997-01-03  0:00 ` Ted Dennison
1997-01-03  0:00 ` Christopher Green [this message]
1997-01-06  0:00 ` David Emery
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox