Re: Kill a process by name
From: Måns Rullgård (mru_at_inprovide.com)
Date: Wed, 09 Nov 2005 20:18:56 +0000
firstname.lastname@example.org (Mark Rafn) writes:
>>> <email@example.com> 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?
>>firstname.lastname@example.org (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 <email@example.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 firstname.lastname@example.org