LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 03-05-2010, 01:08 AM   #1
smitha kulkarni
LQ Newbie
 
Registered: Mar 2010
Posts: 3

Rep: Reputation: 0
want a code for accessing the process control block.


hi guys. i want to access the process control block to retrieve a process' pid and priority. please help me out with the code or the steps to do it.

Last edited by smitha kulkarni; 03-05-2010 at 02:41 AM.
 
Old 03-05-2010, 01:23 AM   #2
Aquarius_Girl
Senior Member
 
Registered: Dec 2008
Posts: 4,731
Blog Entries: 29

Rep: Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940
Quote:
Originally Posted by smitha kulkarni
hi guys. i want to access the process control block to retrieve a process' pid and priority. pls pls help me out with the code or the steps to do it.
getpid() can be used to retrieve a process's PID, do man getpid on your terminal.

For process priority, look here:
http://www.cyberciti.biz/faq/howto-s...ority-process/
and
http://linux.die.net/man/2/nice
and
http://www.comptechdoc.org/os/linux/...processes.html

and finally do not use words like 'pls' on a technical forum, people find them irritating. You can try writing 'please' instead.

Last edited by Aquarius_Girl; 03-05-2010 at 01:25 AM.
 
Old 03-05-2010, 03:30 AM   #3
smitha kulkarni
LQ Newbie
 
Registered: Mar 2010
Posts: 3

Original Poster
Rep: Reputation: 0
program to fetch pid of a running process

hi
we have a program which is running in an infinite while loop. how to fetch the pid of this process.

thanks.
 
Old 03-05-2010, 03:33 AM   #4
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,724

Rep: Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705
With the ps command.

Evo2.
 
Old 03-05-2010, 03:38 AM   #5
smitha kulkarni
LQ Newbie
 
Registered: Mar 2010
Posts: 3

Original Poster
Rep: Reputation: 0
Is there any other way of doing it?? Like a program code to retrieve the pid?
 
Old 03-05-2010, 03:39 AM   #6
Aquarius_Girl
Senior Member
 
Registered: Dec 2008
Posts: 4,731
Blog Entries: 29

Rep: Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940
Try ps -el and lookout pstree for detailed info.
 
Old 03-05-2010, 03:40 AM   #7
Aquarius_Girl
Senior Member
 
Registered: Dec 2008
Posts: 4,731
Blog Entries: 29

Rep: Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940
Quote:
Is there any other way of doing it?? Like a program code to retrieve the pid?
I have answered you in this thread:

http://www.linuxquestions.org/questi...block.-793336/
 
Old 03-05-2010, 03:45 AM   #8
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
There is also
Code:
pidof <process-name>
 
Old 03-05-2010, 07:58 AM   #9
z-vet
Member
 
Registered: Aug 2004
Location: Israel
Distribution: LMDE 5
Posts: 271

Rep: Reputation: 34
+1 for pidof.
 
Old 03-05-2010, 12:51 PM   #10
GrapefruiTgirl
LQ Guru
 
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594

Rep: Reputation: 556Reputation: 556Reputation: 556Reputation: 556Reputation: 556Reputation: 556
smitha kulkarni,

I have merged your two nearly identical threads since they each had had some replies on them.

Please try to keep questions specific and post them in one place only, rather than posting the same question two different ways in two different places.

Kind regards,
Sasha
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Getting PID of running process in C/C++ laikos Programming 16 10-30-2015 06:16 PM
running a program in the background in the child emulator process yosato_uk Linux - General 2 08-26-2009 10:10 AM
How to get the PID of the process giving kill signal to a process? hariprd Programming 2 11-27-2008 03:10 AM
program to check to make sure a process is running? IceNineJon Linux - Software 7 08-06-2003 02:07 PM
How to determine whether a PROCESS is running, by a SHELL program? yuzuohong Linux - General 4 01-21-2003 08:41 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 05:18 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration