Abnormal Interpreter Shutdown

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • k3xji

    Abnormal Interpreter Shutdown

    Hi all,

    Is there anyway to detect abnormal interpreter shutdown like (closing
    from task manager, power shutdown of the PC..etc)?

    Regards,
  • Tim Golden

    #2
    Re: Abnormal Interpreter Shutdown

    k3xji wrote:
    Hi all,
    >
    Is there anyway to detect abnormal interpreter shutdown like (closing
    from task manager, power shutdown of the PC..etc)?
    "Task Manager" suggests you're using Windows, on which basis
    you've got a few options open to you, but fundamentally if
    someone pulls the plug on the PC you're not going to spot it.

    Look at the SetConsoleCtrlH andler API[1], which is available
    in the pywin32 package, and the WMI power events[2]. I don't
    know exactly how far each one will go if someone stomps on
    your process, but they're definitely worth looking at.

    TJG

    [1] http://msdn.microsoft.com/en-us/libr...16(VS.85).aspx
    [2] http://msdn.microsoft.com/en-us/libr...62(VS.85).aspx

    Comment

    • Terry Reedy

      #3
      Re: Abnormal Interpreter Shutdown

      Tim Golden wrote:
      k3xji wrote:
      >Hi all,
      >>
      >Is there anyway to detect abnormal interpreter shutdown like (closing
      >from task manager, power shutdown of the PC..etc)?
      >
      "Task Manager" suggests you're using Windows, on which basis
      you've got a few options open to you, but fundamentally if
      someone pulls the plug on the PC you're not going to spot it.
      >
      Look at the SetConsoleCtrlH andler API[1], which is available
      in the pywin32 package, and the WMI power events[2]. I don't
      know exactly how far each one will go if someone stomps on
      your process, but they're definitely worth looking at.
      >
      TJG
      >
      [1] http://msdn.microsoft.com/en-us/libr...16(VS.85).aspx
      [2] http://msdn.microsoft.com/en-us/libr...62(VS.85).aspx
      If you mean detecting abnormal shutdown after the fact, as opposed to
      catching it while happening, you could create an empty temp file when
      the program starts and delete it upon normal termination.

      Comment

      • k3xji

        #4
        Re: Abnormal Interpreter Shutdown

        If you mean detecting abnormal shutdown after the fact, as opposed to
        catching it while happening, you could create an empty temp file when
        the program starts and delete it upon normal termination.
        I have a server application, and I want to take some actions *before*
        the shutdown. I assumed to have some kind of event or Exception being
        raised when Interpreter is closed abnormally.

        I will take a look at the links.

        Thanks a lot.

        Comment

        • k3xji

          #5
          Re: Abnormal Interpreter Shutdown


          I think what I am looking for is SetConsoleCtrlH andler(..) which
          receives signals for CTRL+C and system shutdown. I don't want to take
          the power outage into account because as far as I can see there is no
          portable/simple/reliable way to accomplish that. So, thanks for the
          tip again.

          So what is the equivalent of this API in Linux? How can I accomplish
          the same behavior for Linux?

          Thanks a lot.

          Comment

          • Gabriel Genellina

            #6
            Re: Abnormal Interpreter Shutdown

            En Tue, 21 Oct 2008 05:07:34 -0200, k3xji <sumerc@gmail.c omescribió:
            I think what I am looking for is SetConsoleCtrlH andler(..) which
            receives signals for CTRL+C and system shutdown. I don't want to take
            the power outage into account because as far as I can see there is no
            portable/simple/reliable way to accomplish that. So, thanks for the
            tip again.
            >
            So what is the equivalent of this API in Linux? How can I accomplish
            the same behavior for Linux?
            Using signal - see http://linux.die.net/man/7/signal and signal(2)

            --
            Gabriel Genellina

            Comment

            • Terry Reedy

              #7
              Re: Abnormal Interpreter Shutdown

              k3xji wrote:
              I think what I am looking for is SetConsoleCtrlH andler(..) which
              receives signals for CTRL+C and system shutdown. I don't want to take
              the power outage into account because as far as I can see there is no
              portable/simple/reliable way to accomplish that. So, thanks for the
              tip again.
              If your hardware is connected to a UPS (uninterruptabl e power supply aka
              battery backup) that signals the OS when power has gone and it has
              switched to the battery, you should be able to respond to that also.

              Comment

              Working...