![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| get program name give a process id | naren_chella | HP-UX | 1 | 09-01-2006 04:33 AM |
| possible to run script to enter info within a program? | lianderthal | Shell Programming and Scripting | 1 | 06-09-2005 03:40 PM |
| Linux process info | nayeemmz | Linux | 2 | 02-09-2005 03:43 PM |
| IO by Process/program | cpiuk | HP-UX | 2 | 09-16-2004 01:24 AM |
| How can I get the file info of my process?ugent!!!!! | nsun | High Level Programming | 2 | 07-02-2003 06:02 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Getting process info in a program
Hi,
I am wondering if there is a way to find out in a C software program if a particular process is running without having to write a file. In the past, I have been using the system command to execute a pgrep and output the info to a file. Then the C program reads the file to make the determination, and the file is deleted. I have a request from my customer to find out this same info in the C program without writing a file. HP-UX has a pstat_getproc utility that would work, but this is not supported in most Unix variants. Is there some other way for a software program to detect if another process is running? Thanks, Herb Miller |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
Depends on the platforms you're supporting
Most flavors of UNIX support process accounting on some level, but each of them implement it a little differently. Both AIX and Solaris have process structs available in the /usr/include/sys/proc.h files. You may have to do a bit of digging to find a method to give you back exactly what you want, but that's a place to start.
The only exception to this is Linux, which doesn't have the process accounting libraries that most of the other UNIXs have. Process accounting in Linux is done through the /proc filesystem, which are nominally a set of files updated with the necessary process info in real time. If you're looking to accomplish this on Linux, you'll need to do some digging to find out what's relevant. Of course, if you're just looking for basic info, you can have your program run the 'ps' command and parse the output. Hope that helps. |
|||
| Google The UNIX and Linux Forums |