Sponsored Content
Full Discussion: [C] Process pid by name
Top Forums Programming [C] Process pid by name Post 302334599 by Dedalus on Thursday 16th of July 2009 04:45:57 AM
Old 07-16-2009
[C] Process pid by name

Hi

I use linux OS.
I've already written a function that allow me to get the process name by pid. (searching in /proc). Now I'd like to perform the inverse task.I mean get the process pid by its name.

I could write a function that search in every folder in /proc for the process name, but i think that should be another solution. Something like include a kernel structure that keep information on the active process.

Can you suggest me another way? or some references where i can study?

Thx

D.
 

10 More Discussions You Might Find Interesting

1. Programming

Child Process PID

Hi, Can anybody solve this query? A parent process forks 2 child processes. How does the child process know it's PID without the parent process sending it. Apart from the "ps-ef" option, what other options are there if any? (2 Replies)
Discussion started by: skannan
2 Replies

2. Shell Programming and Scripting

Process PID

Hi Friends :p I have a little problem please help me out. I have a Unix based OS Sun Server having oracle 8i as database on it. The server has one client with windows OS. The client uses developer 2000 (GUI) to run query and run processes. I want to know how can I know the PID of a process run... (3 Replies)
Discussion started by: vanand420
3 Replies

3. Solaris

getting pid of process

hi all, Is there a simple script anyone could through out to me, to find the pid of a process given the name. I actually need to bind this pid to a processor set. I would probably put these comamns in a shell script which would have. a) kick start the executable b) get the pid c) bind it to a... (10 Replies)
Discussion started by: Naanu
10 Replies

4. UNIX for Dummies Questions & Answers

Need to get pid of a process and have to store the pid in a variable

Hi, I need to get the pid of a process and have to store the pid in a variable and i want to use this value(pid) of the variable for some process. Please can anyone tell me how to get the pid of a process and store it in a variable. please help me on this. Thanks in advance, Amudha (7 Replies)
Discussion started by: samudha
7 Replies

5. Shell Programming and Scripting

Get an PID of particular process

Hi I have written a shell script to find and kill the particular process. Here in shell script i have written the code like cnt = $(ps -ef | grep Shree) echo $cnt I am getting the output root 2326 2317 0 14:39:46 pts/1 0:28 Shree -f fdc.fbconf FDCapp.fbapp Here I want to... (2 Replies)
Discussion started by: Shreedhar Naik
2 Replies

6. Shell Programming and Scripting

getting pid from a process

Hi all, i was able to redirect pid of process to a file in the following way ps aux|awk '$11 == "/Applications/ProjectX/DServer" >> /Applications/ProjectX/DServer.pid it works fine but if one folder name caontains space its not working like below ps aux|awk '$11 == "/Applications/Project\... (1 Reply)
Discussion started by: kirankumars
1 Replies

7. AIX

AIX: PID 0 Process

Hi All, I searched other threads and could not find any relevant post about this. I searched for process 0 in SUN OS and could find the sched/swapper process listed. root 0 0 0 Apr 25 ? 0:06 sched but i couldnt not find the swapper process (PID 0) in AIX. Is that... (4 Replies)
Discussion started by: quintet
4 Replies

8. HP-UX

PID Process Resources

Hi all. I need to get detailed information about a PID. I have an app called Reflection X and it shows many things like Total CPU percent, User CPU (Nice) percent, FS Reads, etc. My question is how can I get all that information on console? Is there an archive with the detailed... (9 Replies)
Discussion started by: the0m3n
9 Replies

9. AIX

Swapper Process #PID more than 1

Hi I would like to know more about swapper process.. I knew that swapper is the first process with PID#0, used to perform process swap operations. It used to swap entire processes But sometimes I find swapper process with PID#264 So my doubt is how many swapper process can exist in a system?... (2 Replies)
Discussion started by: Priya Amaresh
2 Replies

10. AIX

How to get process name from PID?

HI, i used ps -ef | grep 3539052 | grep -v grep and i got a output like ths root 3539052 3407918 0 May 07 - 709:31 /usr/sbin/syslogd but what i need is instead of full path /usr/sbin/syslogd i want only the process name that is 'syslogd' here. (3 Replies)
Discussion started by: sumanthupar
3 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 01:30 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy