Re: Kill a process by name

From: Måns Rullgård (mru_at_inprovide.com)
Date: 11/09/05


Date: Wed, 09 Nov 2005 20:18:56 +0000

dagon@dagon.net (Mark Rafn) writes:

>>> <lambert54@cox.net> wrote:
>>>>In an executable written in C, is there a way to kill a process that
>>>>all you know is the name of the process and nothing else?
>
>>dagon@dagon.net (Mark Rafn) writes:
>>> 1) find the PIDs of the processes to kill. This is somewhat of a pain and
>>> unlikely to be portable at all without using shell tools. You may be able
>>> to sift through information in /proc on some systems.
>>> 2) send a signal to those processes. kill(2) does this easily.
>
> Måns Rullgård <mru@inprovide.com> wrote:
>>The hard part is making sure those PIDs are still valid by the time
>>you kill(2) them.
>
> Sure, but that's a problem the OP has to ignore when doing it by hand or by
> using a shell pipeline too.

True, which is why relying on sending signals to processes you did not
start yourself is usually a bad idea.

-- 
Måns Rullgård
mru@inprovide.com