# Killing a process whose parent is init



## MMacD (Sep 16, 2018)

I have a `grep` process that refuses to die..  I did kill the shell job that was its parent, but that didn't kill the child, which is now parented by PID 1 (init).

I've tried both the plain `kill nnnn` and the fancy `kill -s KILL nnnn`.  The fancy one gets me the complaint that arguments should be jobs or process ids.  Neither one works.

Is there any way to kill the `grep` process apart from rebooting?


----------



## ShelLuser (Sep 17, 2018)

Not sure from mind, but if you run ps then what's it's state right now? That might give us more clues.


----------



## jiml8 (Sep 17, 2018)

as root, "kill -9 nnnn" should work.


----------



## ralphbsz (Sep 17, 2018)

Most likely, the process has an IO problem.  What is it reading from, what is it writing to?  As ShelLuser asked: what is it's state?  Is the rest of the system functioning normally?  Any error messages regarding disks or IO in dmesg or /var/log/messages?

If the root cause is a serious IO problem, you may have to reboot anyway.


----------



## sidetone (Sep 17, 2018)

I've had that problem too. For some processes `pkill` wouldn't work, and neither would `kill -9 ####`, after finding the id. The only way these processes would die, is if I launched from the terminal, without backgrounding `&bg` them, then typing ctrl-c. `xkill` should work for graphical programs, but I couldn't get the hang of controlling it.


----------



## MMacD (Sep 17, 2018)

Thanks, guys.  Apparently it went into a decline after my multiple attempts to kill it, and finally died overnight.

I might reboot anyway, because that error message--which I've never seen before--looked fishy to me and isn't mentioned in kill(1)().


----------



## mFP (Sep 17, 2018)

Well the error message seems to indicate that you've put the process ID at the wrong place, i.e. kill expected a process number but found something else instead.

Also as others have pointed out using ps to get more information about the process state is really helpful to diagnose what the problem might be. 
I suspect it might have been as simple as `kill <pid>` not working because SIGKILL was needed and you somehow you mistyped that.


----------



## sidetone (Sep 18, 2018)

mFP said:


> Well the error message seems to indicate that you've put the process ID at the wrong place, i.e. kill expected a process number but found something else instead.
> 
> Also as others have pointed out using ps to get more information about the process state is really helpful to diagnose what the problem might be.
> I suspect it might have been as simple as `kill <pid>` not working because SIGKILL was needed and you somehow you mistyped that.


No.


----------

