Finding process which ended another process


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Finding process which ended another process
# 1  
Old 06-15-2011
Finding process which ended another process

Hello,
The scenario is as follows, I have a background process running initially for which i know the PID on machine1. I use ssh from machine 2 to execute a script in machine 1. For some reason the back ground process is terminated. I would like to know which process caused the termination of this background task. is there any ideas to monitor this ?

Thanks in advance
# 2  
Old 06-15-2011
Well, it might be a bit of a job. Signals like kill -9 do not involve a party that logs, the sender sends the signal the the recipient dies.

But, there is always a way. You can replace the entire libc or whetver lib kill(2) and signal() or whatever send the signals lives, with a library you augment with the desired logging if a signal is sent. All calls in the new libc have to call syscall() to get to the original calls in the original, renamed library. I read about this in a product that created restart points with no cooperation of the applications! Heady stuff!
# 3  
Old 06-15-2011
If you are using Solaris 10, then this will show who killed your process and how:
Code:
dtrace -n 'proc:::signal-send/args[1]->pr_pid==your_proc_pid/{printf ("user with UID %d sent signal %d using %s",uid,args[2],execname);}'

# 4  
Old 06-15-2011
After the fact, from a log? I guess, before the pid recycles, or all such messages for that pid?
# 5  
Old 06-16-2011
Quote:
Originally Posted by DGPickett
After the fact, from a log? I guess, before the pid recycles, or all such messages for that pid?
If you are asking about that DTrace one-liner - it should be run when the process is alive, and it should be kept running (preferably in background, redirecting the output to some file). When the process in question receives any signal, then DTrace will detect that call and print the information about who sent it.
# 6  
Old 06-16-2011
Ok, it is somewhat like using a live process with truss/tusc/strace or a debugger. Is it low overhead? Truss is definitely not!
# 7  
Old 06-16-2011
It may seem like running debugger on an application, but it most certainly is not. Debuggers intercept all the application's instructions introducing huge delays. DTrace on the other hand is built deeply into Solaris kernel, firing off its code only when instructed to trace some particular event, which is done by DTrace probes. By default all the probes are disabled. When DTrace code like above is executed, Solaris kernel substitutes small piece of its own assembly code with instructions informing DTrace framework about particular event. This code is only executed when traced event happens. This behavior results in literally no overhead when tracing rare events like sending signals to applications and very small overhead when tracing larger number of very often occurring events.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Finding a file process ?

Hi, I am trying to find a file that have a different name than it should be processing, the file name is ( Fifa15 ) is there a command to use? I got that file by ps -ef | grep fifa15 but how do I know what is running ? thanks a lot, I am learning unix so sorry if that is a... (2 Replies)
Discussion started by: latinooo
2 Replies

2. UNIX for Dummies Questions & Answers

Process which ended another process

Hello, The scenario is as follows, I have a background process running initially for which i know the PID on machine1. I use ssh from machine 2 to execute a script in machine 1. For some reason the back ground process is terminated. I would like to know which process caused the ... (1 Reply)
Discussion started by: prasbala
1 Replies

3. Shell Programming and Scripting

Testing a process has ended (in the background)

Hi guys. Hopefully this question will make sense! Continuing on my script to automatically copy some huge files across the network onto various servers as background jobs, I need to be able to check that each job has finished successfully. The script below shows what I want - almost. The... (2 Replies)
Discussion started by: dlam
2 Replies

4. UNIX for Dummies Questions & Answers

Finding a rogue process

Afternoon all, hopefully someone can give me a hand with this (the following may be explained very poorly :rolleyes: ) I know there's a process running on one of our Solaris 10 boxes that runs approximately every 5 minutes. Unfortunately I've no idea, who owns it, what it is called, or how it is... (2 Replies)
Discussion started by: dlam
2 Replies

5. UNIX for Advanced & Expert Users

Finding process id of subsequent process

hi all, I am trying to find the process id of the subsequent process created via fork and exec calls in perl. For eg: envVarSetter dataCruncher.exe < input.txt > output.txt When I fork and exec the above command, it returns only the pid of envVarSetter and I don't know how to find the... (9 Replies)
Discussion started by: matrixmadhan
9 Replies

6. Shell Programming and Scripting

Finding the process id of the process using the ports

Hi Any idea how to get the process id of the process using the ports lsof -i :portnumber does not work in my machine. I am on sun Solaris SPARC. Any suggestion is highly appreciated (1 Reply)
Discussion started by: kinny
1 Replies

7. Linux

Need help in finding process

Hello, Iam running a apache webserver in CentOS recenlty a hacker has attacked my server using RFI attack and did something in my server.. After that everyday at 8Pm my httpd is using about 5000 pid's actually in normal it takes only about 30 - 40 pid's. and also exim uses 2000 pid's totally my... (2 Replies)
Discussion started by: dheeraj4uuu
2 Replies

8. UNIX for Dummies Questions & Answers

Finding out process id in a scipt

Hi, If in a shell script i write a command ls > bla & ls The output is redirected to bla and the next ls starts as first one is going on in background. I want to find the PID of the first command. Thanks in advance (2 Replies)
Discussion started by: vibhor_agarwali
2 Replies

9. UNIX for Dummies Questions & Answers

finding process id

is there a way to find the process id of a process because i have same process invoked several times. when i need to kill them, i get confused with the id. Thanks, sskb :( (8 Replies)
Discussion started by: sskb
8 Replies

10. UNIX for Advanced & Expert Users

Finding Out When A Process Has Finished?

Problem I have an application which basically runs lots of UNIX programs remotely, using the Telnet protocol. For each program it remotely executes, it stores the process ID (PID) for that process. At regular intervals, I would like my application to take the PID for every process still... (5 Replies)
Discussion started by: 1cuervo
5 Replies
Login or Register to Ask a Question