LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   I try kill <pid> but program still appearws if I use ps (https://www.linuxquestions.org/questions/linux-newbie-8/i-try-kill-pid-but-program-still-appearws-if-i-use-ps-925604/)

acomber 01-25-2012 04:00 AM

I try kill <pid> but program still appearws if I use ps
 
Hello

I ran a server program (ie a program which runs and never stops) and after a while used Ctrl Z to stop the program.

Then I looked at running processes using ps and found it was listed there. so I noted the pid and ran kill <thepid>. no error seen in doing this.

Then I check using ps again and program is still listed?

Does this mean the program is still actually running? Or does it show recent processes? Or am I doing something wrong?

Angus

T3RM1NVT0R 01-25-2012 04:38 AM

@ Reply
 
Hi Angus,

Welcome to LQ!!!

You have to send kill signal to terminate the process. You can do this using following command:

Code:

kill -9 <pid of that process>
-9 is the kill signal.

deep27ak 01-25-2012 04:38 AM

type this command and check the output

Code:

#jobs

Satyaveer Arya 01-25-2012 05:07 AM

Quote:

# ps aux | grep name_of_process
At the command line type: kill -9 PID_Number_Here

You can also type:

Quote:

# killall -9 name_of_process
which will kill any process with that name.

Or

Quote:

# kill -s9 name_of_process

acomber 01-25-2012 06:26 AM

Quote:

Originally Posted by T3RM1NVT0R (Post 4583912)
Hi Angus,

Welcome to LQ!!!

You have to send kill signal to terminate the process. You can do this using following command:

Code:

kill -9 <pid of that process>
-9 is the kill signal.

Ah the -9 was the missing crucial piece. Many thanks.

deep27ak 01-25-2012 06:31 AM

Quote:

Originally Posted by acomber (Post 4583983)
Ah the -9 was the missing crucial piece. Many thanks.

good to know you found the solution

and next time use this command to look out for stopped or zombie process before you reach to a conclusion that you have sucessfully killed any process

Code:

#jobs
so why don't you mark the thread as solved to help others as well :cool:

acomber 01-25-2012 06:40 AM

Quote:

Originally Posted by T3RM1NVT0R (Post 4583912)
Hi Angus,

Welcome to LQ!!!

You have to send kill signal to terminate the process. You can do this using following command:

Code:

kill -9 <pid of that process>
-9 is the kill signal.

Thanks, I have investigated further and if I do not specify the signal to send then SIGTERM is sent. I presume the application had a handler for SIGTERM and just carried on running. No program can handle SIGKILL (-9) (as far as I am aware) so that did the trick.

T3RM1NVT0R 01-25-2012 07:26 AM

@ Reply
 
You're welcome.

Yes, you are right that no program can trap KILL SIGNAL.

Enjoy linux!!!

catkin 01-25-2012 08:24 AM

When processes are killed with SIGKILL they have no opportunity to clean up before they stop so data may be lost and files may be left in an uncoordinated state. For these reasons, if the application can be stopped by any other signal, that signal should be used. SIGKILL is a last resort (unless you want the process to have no opportunity to save its data :D ).


All times are GMT -5. The time now is 02:14 PM.