Sponsored Content
Full Discussion: Implement ps command in C
Top Forums Programming Implement ps command in C Post 302873027 by Don Cragun on Monday 11th of November 2013 03:24:55 AM
Old 11-11-2013
The details provided by the /proc filesystem (and even if it exists) varies widely from system to system. On systems where it is present, it reflects data found in the kernel's process table (which also varies considerably from system to system).
Code:
man /proc

may provide information about how /proc is implemented on your system.

Unlike many "standard" utilities, the code needed to implement ps is not at all portable. On systems that don't support /proc, ps is frequently a set-UID root process that extracts data directly from the kernel's process table by reading /dev/kmem (another interface that is not available on all systems).
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

how can i implement rlogin

how can i use a rlogin with out entered a password, someone tell me about configure the next files /.rhosts /etc/hosts.equiv and /etc/hosts but i not sure about that, or there are not enough could you tell me how to do that? (3 Replies)
Discussion started by: jav_v
3 Replies

2. Programming

how does va_arg implement ?

1 . How does va_arg implemented by system? (2 Replies)
Discussion started by: chenhao_no1
2 Replies

3. Shell Programming and Scripting

how to implement this

Hi all, could any of you please help me on my problem.. we are doing FTP (one report out put) from one server to another server through unix shell script program. Due to the network issues, some times FTP process is hanging. So we planned to modify the existing program with the following... (2 Replies)
Discussion started by: kishore_jasthi
2 Replies

4. Shell Programming and Scripting

Trying to implement case

Hi All, My requirement is if the record is starting with 0, then do some processing. if starting with 1, some processing else (not with 0 or 1 ) then do some other processing. i tried the following case "$test" in /^0/) echo "starting with zero ;; /^1/) echo " with one" ;; *) echo... (2 Replies)
Discussion started by: ssunda6
2 Replies

5. Shell Programming and Scripting

Trying to implement 'more' command

Hi all, i'm quite new in the UNIX world. So maybe i'm going to ask simple questions but they are unsolvable for me... I'm trying to implement the 'more' function or kinda of that, for improving my knowledges. But I encountered some problems that i hope u will help me to solve. The code i... (0 Replies)
Discussion started by: Cellofan
0 Replies

6. Solaris

new - How i can implement Mirroring

Unix is something new for me, I trying learn about it now. I have download the sun virtualbox software and install solaris 10 into it. It is is like wizard with step by step installation guideline. :) NOw how can i implement mirroring(RAID) into the my new SunOS? can anyone give a briefly list... (14 Replies)
Discussion started by: webster5u
14 Replies

7. Shell Programming and Scripting

How to implement this?

hi i have a file like 1,"A","B" 2,"C","D" 1,"E","F" 3,"G","H" in output i need like 3,"G","H" 1,"E","F" 2,"C","D" 1,"A","B" (12 Replies)
Discussion started by: angel12345
12 Replies

8. Shell Programming and Scripting

How to implement a command n times?

I need to run a command n (n >= 100) times and the command running may take about 30 seconds. Can anyone help me with the shell script to achieve this? Thanks in advance. (5 Replies)
Discussion started by: zwei2011
5 Replies

9. Homework & Coursework Questions

How to implement wc command using awk?

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: Here in flwng code \n is not working 2. Relevant commands, code, scripts, algorithms: Files: a.txt This... (0 Replies)
Discussion started by: sidpatil
0 Replies

10. UNIX for Beginners Questions & Answers

How to implement a simple command/code for multiple files?

I have been extracting a row, based on multiple key word from a xls/csv file, by using the following command. I have to implement the same for multiple xls/csv files, therefore please help me to do the same. awk ' { tbp=0 if ($0 ~ keyword1 && k1 == 0) { tbp=1; k1++ } if ($0 ~ keyword2... (2 Replies)
Discussion started by: dineshkumarsrk
2 Replies
kvm_nextproc(3KVM)					    Kernel VM Library Functions 					kvm_nextproc(3KVM)

NAME
kvm_nextproc, kvm_getproc, kvm_setproc - read system process structures SYNOPSIS
cc [ flag... ] file... -lkvm [ library...] #include <kvm.h> #include <sys/param.h> #include <sys/time.h> #include <sys/proc.h> struct proc *kvm_nextproc(kvm_t *kd); int kvm_setproc(kvm_t *kd); struct proc *kvm_getproc(kvm_t *kd, pid_t pid); DESCRIPTION
The kvm_nextproc() function reads sequentially all of the system process structures from the kernel identified by kd (see kvm_open(3KVM)). Each call to kvm_nextproc() returns a pointer to the static memory area that contains a copy of the next valid process table entry. There is no guarantee that the data will remain valid across calls to kvm_nextproc(), kvm_setproc(), or kvm_getproc(). If the process structure must be saved, it should be copied to non-volatile storage. For performance reasons, many implementations will cache a set of system process structures. Since the system state is liable to change between calls to kvm_nextproc(), and since the cache may contain obsolete information, there is no guarantee that every process structure returned refers to an active process, nor is it certain that all processes will be reported. The kvm_setproc() function rewinds the process list, enabling kvm_nextproc() to rescan from the beginning of the system process table. This function will always flush the process structure cache, allowing an application to re-scan the process table of a running system. The kvm_getproc() function locates the proc structure of the process specified by pid and returns a pointer to it. Although this function does not interact with the process table pointer manipulated by kvm_nextproc(), the restrictions regarding the validity of the data still apply. RETURN VALUES
On success, kvm_nextproc() returns a pointer to a copy of the next valid process table entry. On failure, it returns NULL. On success, kvm_getproc() returns a pointer to the proc structure of the process specified by pid. On failure, it returns NULL. The kvm_setproc() function returns 0 on success and -1 on failure. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Interface Stability |Stable | +-----------------------------+-----------------------------+ |MT-Level |Unsafe | +-----------------------------+-----------------------------+ SEE ALSO
kvm_getu(3KVM), kvm_open(3KVM), kvm_kread(3KVM), attributes(5) SunOS 5.10 2 May 2002 kvm_nextproc(3KVM)
All times are GMT -4. The time now is 06:12 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy