From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=0.6 required=5.0 tests=BAYES_20,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,4c7b60aff78f20a7 X-Google-Attributes: gid103376,public From: cgreen@yosemite.atc.com (Christopher Green) Subject: Re: How to query active processes from Ada Date: 1997/01/03 Message-ID: <5ajroq$51l@newshub.atmnet.net>#1/1 X-Deja-AN: 207534980 references: <5aj97p$a9m@news.spar.ca> organization: Advanced Technology Center, Laguna Hills, CA newsgroups: comp.lang.ada Date: 1997-01-03T00:00:00+00:00 List-Id: In article <5aj97p$a9m@news.spar.ca>, James d'Eon 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