shell - Kill Process from Command Name -


in project need write function take name of command in parameter, , kill process executing command. don't know how go problem. can me please?

assuming mean linux/unix: capture process id of command, can use pgrep:

pgrep command 

this returns process id integer, can pass kill.

kill -9 $(pgrep command) 

command extended regex pattern - pgrep test match commands called test, pgrep *test* match test, tester, bashtest etc. may have access pkill, similar skips step directly killing process matched.


Comments

Popular posts from this blog

python 3.x - Mapping specific letters onto a list of words -

javascript - jquery or ashx not working -

inno setup - TLabel or TNewStaticText - change .Font.Style on Focus like Cursor changes with .Cursor -