PID status


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting PID status
# 1  
Old 03-22-2010
Question PID status

Given a PID ( suppose 1356) . How do i tell if its running or not

It would be really helpful if you could explain me ..

I got this answer from google but i am unable to understand it

**********************************************

Use kill() with 0 for the signal number.
There are four possible results from this call:
kill() returns 0

this implies that a process exists with the given PID, and the system
would allow you to send signals to it. It is system-dependent whether
the process could be a zombie.

kill() returns @math{-1}, errno == ESRCH

either no process exists with the given PID, or security enhancements
are causing the system to deny its existence. (On some systems, the
process could be a zombie.)

kill() returns @math{-1}, errno == EPERM

the system would not allow you to kill the specified process. This
means that either the process exists (again, it could be a zombie) or
draconian security enhancements are present (e.g. your process is not
allowed to send signals to anybody).


kill() returns @math{-1}, with some other value of errno

you are in trouble!


***********************************************
# 2  
Old 03-22-2010
Hello,
As long as you see your PID in ps command output, your process is running. If you want to check your PID's parent/child process you can use ptree <PID>

-Nithin.
# 3  
Old 03-22-2010
To get parent/child processes from a pid I do the following on a sco unix box:

ps -ef | grep pid#
# 4  
Old 03-22-2010
ok thanks that was really clever way out ..

Google confused me ....
# 5  
Old 03-22-2010
Quote:
Originally Posted by bsnithin
Hello,
As long as you see your PID in ps command output, your process is running. If you want to check your PID's parent/child process you can use ptree <PID>

-Nithin.
And as an addition you can use pargs <PID> to check the arguments of the process.

Besides you can check /proc directory too

Regards
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help with finding the exit status of a 'nohup' command using 'PID'.

Hello All, I need to run a set of scripts, say 50 of them, parallely. I'm running these 50 scripts, from inside a script with the help of 'nohup' command. 1.The fifty scripts are stored in a separate file. 2.In a master script, i'm reading every line of the file through loop and executing... (4 Replies)
Discussion started by: SriRamKrish
4 Replies

2. SCO

PANIC: exit - cannot exec /etc/init (PID 1), status 0*00000200

Hi to all, I hope that you can help me with this... SCO Unix 5.0.5, old mashine Pentium III x86, SCSI HDD 36.4 Gb PANIC: exit – Cannot exec /etc/init (PID 1), status 0x00000200 Cannot dump 49055 pages to dumpdev hd (1/41) : space for only 48640 pages Dump not completed Safe to Power Off... (1 Reply)
Discussion started by: lakicevic
1 Replies

3. SCO

PANIC: exit - cannot exec /etc/init (PID 1), status 0*00000200.

hi all when ever i power on my sco server it give me the message:PANIC: exit - cannot exec /etc/init (PID 1), status 0*00000200. its not booting. any help?? (1 Reply)
Discussion started by: Danish
1 Replies

4. Red Hat

How to kill a TCP connection which has status TIME_WAIT & no PID

Hi, I want to kill TCP connections which have status as TIME_WAIT & no PID (as per the output of the "netstat - p" command). Is there any command/utility available to kill connections to a specific port or IP address. The problem is that these connections don't have process ID (see... (4 Replies)
Discussion started by: Davinder31may
4 Replies

5. Shell Programming and Scripting

Check process running Status with PID

Good day I am fairly new to Shell Scripting. I want a script to check if a process is up by checking the process's PID and then return a value for when it's running which would be 0. If it isn't running it should give any other value that 0. Any Help is appreciated Regards (9 Replies)
Discussion started by: 1nsyz1on
9 Replies

6. Shell Programming and Scripting

Checking Status of PID

I'm developing a script that spawns many background processes that will be executing concurrently and need to check the exit status of each spawned process after it terminates. After starting the background process I can get the pid from $! which I can store in an associative array but how do I... (2 Replies)
Discussion started by: twk
2 Replies

7. 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

8. Shell Programming and Scripting

Script to check status of a PID

i'm just learning scripting, and have been banging my head against this I want to check if my WAS6 java process is running and if so..echo me a messages. If not then echo me a different messages the problem i have is I dont know how to represent a NULL return value. If i grep for a was6... (14 Replies)
Discussion started by: zeekblack
14 Replies

9. UNIX for Dummies Questions & Answers

Session PID & socket connection pid

1. If I use an software application(which connects to the database in the server) in my local pc, how many PID should be registered? Would there be PID for the session and another PID for socket connection? 2. I noticed (through netstat) that when I logged in using the my software application,... (1 Reply)
Discussion started by: pcx26
1 Replies

10. Programming

printing ppid,child pid,pid

question: for the below program i just printed the value for pid, child pid and parent pid why does it give me 6 values? i assume ppid is 28086 but can't figure out why there are 5 values printed instead of just two! can someone comment on that! #include<stdio.h> #define DIM 8 int... (3 Replies)
Discussion started by: a25khan
3 Replies
Login or Register to Ask a Question