I have launched iperf
in daemon mode with iperf -s -D
and now I want to stop the service.
I tried to use sudo kill pid
but it neither work nor complain. The daemon is still running when I check through ps -ef | grep iperf
.
As it is not launched by Linux, I cannot find it through service
as other daemons.
How could I stop it?
Best Answer
Don't use
kill -9
! This command is meant to be used in some specific extreme cases only.According to the man page (on my Solaris box):
When you don't specify any signal, kill will send SIGTERM (
kill -15
) to your process. There are more aggressive signals you can send that are less violent than SIGKILL (kill -9
).Why avoid kill -9?
SIGKILL is a very violent signal. It cannot be caught by the process, which means that the process that recieves it has to drop everything instantly and exit. It doesn't take the time to liberates resources it has locked (like network sockets or files) nor to inform other processes of exiting. Often, it will leave your machine in an unstable state. Drawing an analogy, you could say that killing a process with SIGKILL is as bad as turning off the machine with the Power button (as opposed to the
shutdown
command).As a matter of facts, SIGKILL should be avoided as much as you can. Instead, as mentioned in the article, it's suggested that you try
kill -2
and if that doesn't workkill -1
.I've seen people rush into sending SIGKILL all the time (even in daily clean up scripts!). I fight with my teammates daily about this. Please, don't use
kill -9
blindly.