Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Process Status

hunt_guyhunt_guy Member Posts: 2
Hello guys,
Is there a system call which i can use to get the process information of some other process using C language. some process control block or something like that

Comments

  • IDKIDK Member Posts: 1,784
    : Hello guys,
    : Is there a system call which i can use to get the process information of some other process using C language. some process control block or something like that
    :
    :
    I'm a noob...
    Maybe look at the source for top...
  • nugentnugent Member Posts: 87
    as far as i know there is no system command to get process info, but if you look in the /proc directory you will see a load of folder that contain only numbers, these are process ID. So if you know the pid of a process you can find certain information about that process by parsing the files in the processes folder under /proc.

    In the folder you'll find files like:

    cmdline - this holds the complete command line of the process

    cwd - a link to the present working directory of the process

    environ - contains the environment for the process (null seperated)

    exe - sym link to the executed command

    fd - a directory containing an entry for each file the process has opened, which is a symlink to the actual file

    maps - contains the currently mapped memory regions and their permissions

    mem - can be used to access the pages of a processes memory through system calls like open and fread

    root - a symlink that points to the processes root of the filesystem (UNIX / Linux support per-process filesystem roots, set by chroot)

    stat - status info of process (used by ps) [should be defined in /usr/src/linux/fs/proc/array.c]

    statm - info about memory status in pages

    status - human readable format of stat and statm

    you can find out pretty much anything you want to about a process by parsing these files.

    ------
    nugent



Sign In or Register to comment.