how does ps work, and can I program the same in C

how does ps work, and can I program the same in C

Post by Jan Bo » Fri, 02 Feb 1996 04:00:00



Hi there,
I want to write my own ps program, but can't find any function calls
for receiving a list of all runnning program's, daemons, defunct
proc's etc.

I'm working on a SCO R3

Kan somebody help please !

--
-----------------------------------------------------------------------------
Telematic Systems & Services B.V.

------------------------------------------------------------------------------

 
 
 

how does ps work, and can I program the same in C

Post by Jeffrey L. Thom » Sat, 03 Feb 1996 04:00:00



>Hi there,
>I want to write my own ps program, but can't find any function calls
>for receiving a list of all runnning program's, daemons, defunct
>proc's etc.
>Kan somebody help please !

there is a device called /dev/kmem that holds the contents of the kernels
memory.  ps uses this with a routine called nlink() (on some systems) to
read in the kernel memory structure.  All of it is system dependant.

I advise you to just give up a do it another way, mabye by opening a pipe
to /bin/ps and reading from it

Jeff
--
\|||/  _Spike_Man_      ____  | Jeffery L. Thomas  | "The important thing is

  v   first superhero  \ SM / | "This time it will | Curiosity has it own
"more than a cute .sig" \__/  | surely run" - anon | reason for existing."

 
 
 

how does ps work, and can I program the same in C

Post by Guy Harr » Sun, 04 Feb 1996 04:00:00



Quote:>I advise you to just give up a do it another way, mabye by opening a pipe
>to /bin/ps and reading from it

...after first checking to see whether your flavor of UNIX has a "/proc"
file system, as, on those systems, you can probably do most, if not all,
of what "ps" does without having to do grubby kernel diving.

SVR4-flavored systems (e.g., SunOS 5.x/Solaris 2.x) has a "/proc" file
system; I think Linux does so as well (albeit a different one), and
4.4-Lite appears to have some stuff to support such a file system as
well, so 4.4-Lite-derived systems may have one.  Some other UNIXes may
have "/proc" or equivalents as well.

 
 
 

how does ps work, and can I program the same in C

Post by Danny R. Faug » Wed, 07 Feb 1996 04:00:00



>SVR4-flavored systems (e.g., SunOS 5.x/Solaris 2.x) has a "/proc" file
>system; I think Linux does so as well (albeit a different one), and
>4.4-Lite appears to have some stuff to support such a file system as
>well, so 4.4-Lite-derived systems may have one.  Some other UNIXes may
>have "/proc" or equivalents as well.

FWIW, on SPP-UX you use the cnx_sysinfo system call.  It's pretty
ugly, but probably not as bad as diving into kmem.
--
Danny Faught -- Convex -- Operating System Demolitions Specialist
"Everything is deeply intertwingled."  (Ted Nelson, _Computer Lib_)
 
 
 

how does ps work, and can I program the same in C

Post by Robert Kl » Fri, 09 Feb 1996 04:00:00




 >>SVR4-flavored systems (e.g., SunOS 5.x/Solaris 2.x) has a "/proc" file
 >>system; I think Linux does so as well (albeit a different one), and
 >>4.4-Lite appears to have some stuff to support such a file system as
 >>well, so 4.4-Lite-derived systems may have one.  Some other UNIXes may
 >>have "/proc" or equivalents as well.
 >FWIW, on SPP-UX you use the cnx_sysinfo system call.  It's pretty
 >ugly, but probably not as bad as diving into kmem.

And on FreeBSD, use the kvm interface instead of /proc (which is _very_
much crippled in comparison to Linux').

                                                                robert

 
 
 

1. How to get ps info from C program without using ps command

Does anyone know how to get to the process information (specifically the
child process ID's of a given process) in a C program without actually
using the ps command (or any other shell command)?  Any pointers would

Thanks!

2. IP over X25 without x.121

3. new PS/2-port and new PS/2-mouse doesn't work

4. PGPlot

5. Matrox Mystique ands X.

6. emu10k1, 2.5.21

7. how do 'plug-ins' work?

8. Best toolkit for X

9. IP Accounting doesn't work for PPP dial-ins :-(( ??

10. Does uemacs really work ins SysV.2?

11. running a DOS program from C program under Linux ?

12. It's not bad canned meat...