How to kill a process that absolutely will not die, OSX terminal

3.2k views Asked by At

Trying to kill an 2 unwanted process left over by a tech company. They both have to do with remote support. One is in root and the other is in user. Nothing is working.

Let's say the PID is 8005, here's what I have tried in terminal: kill 8005, kill -9 8005, kill -KILL 8005, sudo kill 8005, sudo kill -9 8005, pkill -p -9 8005, sudo pkill -P -9 8005

And so on. You get the point.

Every time I attempt to kill, it comes back with a new PID almost instantly. The parent is launchd or kernaltask.

The tech company's response is "we have no idea." Please help!

2

There are 2 answers

1
AudioBubble On

I might have a solution. Backup all of your important files, then follow this tutorial to reset your Mac: Click here to learn how to reset your mac back to original settings/data. You will lose your data, but any installed programs will dissapear and you will be able to start over.

0
Samuel-IH On

This sounds a lot like Launchd, Apple's launch daemon manager.

You may or may not be able to remove it with the following steps:

  1. Locate the pid of the live process

  2. Enter launchctl list | grep PID into terminal while replacing "PID" with the pid of the process. The PIDs will be listed on the left, if you find the culprit in the list, skip to step 4, if not, continue.

  3. Enter sudo launchctl list | grep PID into terminal and replace "PID" with the pid of the process like you did in step 2, you will most likely find a different list of processes this time because now you are filtering through the root daemons.

  4. If you did not find the process identifier in the list, then the process is not being managed by launchctl (so sorry) and the rest of this answer is pretty irrelevant. If you did, however, find the pid: Continue.

  5. The process should have (on the right side) a name in the format of com.blah.blah or something similar. Make sure to remember this.

If you found the pid in step 2:

  1. Go in Finder, Press CMD+Shift+G and type or paste in ~/Library/LaunchAgents and hit "Go" it will bring you to a folder and look around in that folder for a file named "com.blah.blah" aka the name of the service. If you find the file, head over to the last and final step (at the bottom)

If you found the pid in step 4:

  1. Go in Finder, Press CMD+Shift+G and type or paste in /Library/LaunchDaemons and hit "Go" it will bring you to a folder and look around in that folder for a file named "com.blah.blah" aka the name of the service. If you find the file, head over to the last and final step (at the bottom)
  2. Provided you did not find the daemon in the prev step, repeat the last step only going to /Library/LaunchAgents after pressing "CMD+Shift+G" in Finder.

The final step, the one that makes it real!

At this point, you found the launch agent or daemon, and you're ready to terminate it. When you delete the file, after double checking everything, make sure that either you empty your trash immediately after, or delete it by pressing "CMD+Option+Delete", the reason why we do this, is to make sure that the file is actually gone from the OS, not just moved to the .Trashes folder. Depending on the type of service it is, you may need admin privileges, and also you may need to restart your computer.

Cheers, and good luck!



Edit/PS:

If any of you readers feel compelled to edit this answer/make it more clear, be my guest! I'm still learning the ropes here on SO and am doing my best to help others ;)