Windows: Catch 'End process' from the Task Manager

Posted on 2006-05-27
Last Modified: 2013-12-03
I can catch control-C from the keyboard, but I don't know how to catch 'End process' from the Task Manager.

Here's what I've tried.  Note, there is no SIGHUP defined in the signal module.

import sys
import signal
def sighandler(signum, frame):
    print 'Killed'
signal.signal(signal.SIGINT, sighandler)
signal.signal(signal.SIGTERM, sighandler)
signal.signal(signal.SIGABRT, sighandler)
signal.signal(signal.SIGBREAK, sighandler)
# do something in a loop

Question by:todd_pravata
    1 Comment
    LVL 14

    Accepted Solution

    You can't catch End Process, not in Python nor in any other language.  It simply kills the process, without informing it that it's being killed.

    Featured Post

    What Is Threat Intelligence?

    Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

    Join & Write a Comment

    Variable is a place holder or reserved memory locations to store any value. Which means whenever we create a variable, indirectly we are reserving some space in the memory. The interpreter assigns or allocates some space in the memory based on the d…
    Strings in Python are the set of characters that, once defined, cannot be changed by any other method like replace. Even if we use the replace method it still does not modify the original string that we use, but just copies the string and then modif…
    Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
    Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    24 Experts available now in Live!

    Get 1:1 Help Now