How to find a hanging pid


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers How to find a hanging pid
# 1  
Old 01-10-2002
Question How to find a hanging pid

I am trying to write a simple shell script to find a hanging pid and kill it.Any idea how to find a hanging pid??
# 2  
Old 01-10-2002
What exactly do you mean by "hanging" pid?

$! = PID of last background process
$$ = PID of current process (self)
# 3  
Old 01-11-2002
we have a content managemnet tool meant for creating templates.sometimes the app is up&running but when we try to create a template we get an hourglass,at that time is there anyway to tell it's pid is hanging on the unix console??
Moreover,when the app doesn't respond we can't just stop it,we have to use kill -9 to kill it's pids.I hope this will explain what I meant by a hanging pid!!
# 4  
Old 01-11-2002
Its really difficult to say if a Process is hanging, only thing we can do is keep looking at what the process has been doing with the ps. If it is Idle for more than some time, assume it is hanging! This is not a solution, but should help you a little.
shaik786
# 5  
Old 01-11-2002
Hey!! Ravi,
thats an interesting problem. I havent ever heard of any method to find a "Hanging PID" as such. All that I could have done in this case is send harmless signals to the process. A "hanging process" in the foreground wont respond to any signal other than the "Kill -9". This may be used one of the methods to find a "hanging PID" if it doesnt respond to these signals for a "user defined amount" of time depending upon the specific working environment.

This is not a full proof method, but can be considered as one of teh possibilities.

And I dont really think that finding whether process is "idle" can be a right crieteria. Bcoz, "Hanging PID" is not an idle process. It is still running.. besides there may be many process like a telnet session which is not "hanging" but still can be inactive for hours together.

Last edited by jyotipg; 01-11-2002 at 07:46 AM..
# 6  
Old 01-11-2002
Quote:
This is not a solution, but should help you a little.
Any process will Terminate if it does not catch a SIGNAL passed to it, SIGKILL (also SIGSTOP) being a signal which can not be caught. So, where's the room for this "hangin process" not to respond if it has not been written to take care of these signals? Which is like terminating the process with 'kill -9' itself! What if the process has been written to ignore any of the passed signals, again the state of the process is not going to change! What if the process has been written to perform some other task on receipt of any of these signals, the program might deviate from it's original task!

And yes, what are those "harmless signals"?
shaik786
# 7  
Old 01-12-2002
ps -fu <user>

typically when I see a hung PID on my boxes, I can tell that it is hung usually because the run time is very high (somewhat subjective) and the CPU usage is usually very high as well.

We call those "runaway processes". At my work, we use BMC Patrol as a monitoring tool. If the process runs for longer than X minutes, it is flagged and I get a page or email depending on how I have it set to notify me. Also, on HPUX, I have the "top" command and "glance" that help me diagnose system usage.

You can ps -fu user, if you know the user who started the Process and capture the PID if the time and cpu useage is high.

Smilie
 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to find the corresponding command for a existing PID?

Hi All, A process completed already and I have the PID. I want to know the which command used for this PID. 'ps' command and '/proc' folder having the list current process only. Is there a way to search completed process PID? Thanks, Manimuthu (5 Replies)
Discussion started by: k_manimuthu
5 Replies

2. UNIX for Advanced & Expert Users

Find PID using a Port?

Hi, I do not have root user credentials nor do I have the functional id of the process that uses port 80. How can I find the pid of the process using the port number 80 ? Operating System: Linux (6 Replies)
Discussion started by: mohtashims
6 Replies

3. HP-UX

Find port for Pid

Hi, Is this the most appropriate way of finding the listen port number given the pid is "16659" ? lsof -Pan -i tcp -i udp | grep 16659 | grep -i "listen"If so, how can I extract "7001" and assign it to a variable say myport=7001 from the below output which happens to be actual port number? ... (1 Reply)
Discussion started by: mohtashims
1 Replies

4. UNIX for Dummies Questions & Answers

Find PID for a port

Hi, I need to find the PID for a given port on the below system. HP-UX mymachine B.11.31 U ia64 3223107173 unlimited-user license How can I ? (4 Replies)
Discussion started by: mohtashims
4 Replies

5. Shell Programming and Scripting

Find PID for a process

I want to kill a process run by a user of another group. How do I do that..? (3 Replies)
Discussion started by: Haimanti
3 Replies

6. Solaris

how to find PID of a runnign process ?

Hi Friends, How can we find the process ID of a running process using the process name. In AIX I used to use the command "ps -ef | grep <process name>", it used to give me the owner of that process, Process ID and the threads running and the name of the process in the end. However in... (2 Replies)
Discussion started by: sahilsardana
2 Replies

7. Shell Programming and Scripting

KSH 88 - Can I find the PID for an IP connection?

Hi, If I use this command netstat | grep "1268" it shows me all IP addresses connected via port 1268, which is half of what I want. I would like to be able to then map these against a PID on the system, and also thereby get the userid. I have done a couple of days google bashing but... (3 Replies)
Discussion started by: gcraill
3 Replies

8. Shell Programming and Scripting

how to find only PID value

When I run ps -aef | grep aaa.exe it gives out put user 5091 5518 0 10:13:25 pts/1 0:00 grep aaa.exe user 4647 2479 0 09:26:31 ? 0:25 /kk/zzz/user/xxx/bin/aaa.exe user1 1111 2222 0 08:26:31 ? 0:25 /kk/zzz/user1/xxx/bin/aaa.exe I need Only PID value ie... (5 Replies)
Discussion started by: madhusmita
5 Replies

9. UNIX for Advanced & Expert Users

Find PID's

I have a script which spawns multiple compilations. Sometimes due to some errors i have to terminate that script. Now comes the main part, how do I do that? I can see the individual compilations via ps -ef | grep compiler and also kill them via kill -9 pid But the scirpt continues: ... (2 Replies)
Discussion started by: vibhor_agarwali
2 Replies
Login or Register to Ask a Question