0

Is there any way to kill a program that ignores all exceptions? Stupid, I know. I was testing something (since I wasn't sure what error a failed, embedded pig script would throw), forgot to limit the loop to a single day, and now it's just continuously running even though I used

ps -ef

to find and directly kill it. I would just let it run to completion since it will definitely terminate, but it runs hadoop jobs, and is needlessly using up resources/popping up on the terminal in between other tasks randomly. I'd like to avoid shutting my desktop down since I'm running other tasks, but will if it'll kill it...

I got the pid from ps -ef and used kill -9 to directly kill it. It no longer shows up when I run ps -ef | grep but when I leave my terminal sitting for a little bit (even a new window) these "ghost" hadoop jobs show up that correspond to where the killed task would be.

  • `kill -9 ` should take care of it. – dano Jul 08 '14 at 01:33
  • Just to add some info, since we're talking about exceptions, if your code uses `except Exception:`, then `BaseException` won't be catched. Otherwise, the single `except:` statement will catch everything. – cdonts Jul 08 '14 at 01:43

1 Answers1

1

Normally your Python program would need registered listeners to handle any kill signal you send it. See here:

https://stackoverflow.com/a/1112350/276949

There is a special kill signal (SIGKILL, denoted by-9) which will kill your process no matter what.

kill -9 <pid>
Community
  • 1
  • 1
Martin Konecny
  • 57,827
  • 19
  • 139
  • 159
  • The kill-with-no-exceptions signal is called `SIGKILL`, not `-9`. – C. K. Young Jul 08 '14 at 01:37
  • Huh. So if I ran that command to kill it, and it no longer shows up, does that mean the random hadoop jobs are coming from somewhere else? – user2958714 Jul 08 '14 at 01:40
  • 1
    @user2958714 If the hadoop jobs got launched as sub-processes of the Python script, they'd keep running even after you killed the parent. You'd need to find the hadoop job processes and kill those, too. – dano Jul 08 '14 at 01:42
  • 1
    @user2958714 http://linuxg.net/what-are-zombie-and-orphan-processes-and-how-to-kill-them/ - look for "How to find orphaned processes" – Martin Konecny Jul 08 '14 at 01:47