bash - Killing a process in a script -
i'm running weird behavior app i'm using. if start command in background in bash, can kill using
$ command & $ kill -n 2 [pid of command] killing command gracefully
however, when throw script:
command & id=$! kill -n 2 $id
it doesn't @ all. there subtly i'm missing?
edit: clue once script stops running, can't kill command using kill -n 2.
man 7 signal sending signal 2, int, process, interrupt keyboard, why ? people saying send signal 1, why ?
the standard gracefully way kill process signal 15, termination sigal, default used kill.
so use kill "$pid"
then, in case process run subprocess, don't want kill father, want kill them all, use "-$pid" instead of "$pid" kill whole process group, kill think that's -"$pid" signal number, complain, you'll have more precise, :
kill -15 -"$pid"
if program don't want die, use kill -9 -"$pid"
man 7 signal man kill
Comments
Post a Comment