in reply to SetConsoleCtrlHandler Script

As pointed out above, you are passing (the address off) an abritrary lump of string data to the OS kernel and asking it to call this as a function when your process receives a signal. Needless to say, when the OS tries to execute the machine code located at that location, the text "&catch" doesn't translate well into x86 machine code.

Even if you correctly pass the address of your catch subroutine to the OS, it still isn't going to work. The code pointed at by &catch is perl bytecode, not x86 machinecode.


Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"Think for yourself!" - Abigail

Replies are listed 'Best First'.
Re: Re: SetConsoleCtrlHandler Script
by Anonymous Monk on Mar 08, 2004 at 20:54 UTC

    So,

    What can I do that?

    Thanks.

    Jes

      You could take a look at Win32::API::Callback. This is a part of dada's Win32-API-0.41 package. The documentation is minimalist, the best examples are in the samples directory.

      I have no idea whether this would work is conjunction with SetConsoleCtrlHandler, but it's possible. I think that you may well be the first to try to do this, which means you will be on your own for the most part.

      The alternative is to write your own callback wrapper in C or XS. You will need a compiler compatible with the build of Perl you are using. Again, you will be very much on your own getting this to work.


      Examine what is said, not who speaks.
      "Efficiency is intelligent laziness." -David Dunham
      "Think for yourself!" - Abigail
        First, Thanks for help.

        My need is trap logoff and shutdown events in my daemon application.
        I'm not sure the SetConsoleCtrlHandler is the best way.
        What is the way with the same results?

        Jes