Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Intercepting the TerminateProcess event

Intercepting the TerminateProcess event

Scheduled Pinned Locked Moved C / C++ / MFC
questionhelp
5 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    Krischu
    wrote on last edited by
    #1

    In the vein of my CreateProcess() question in a parallel thread today I'm facing the problem of letting the called subprocess doing some tidying up work before really following the termination signal. Would that be possible? Or would it be better to send the process a different signal (in UNIX that would have been a USR signal) and wait a time period for receiving the termination event and if that does not occur in time, then terminating it brute force? Is the TerminateProcess an unconditional signal that cannot be intercepted by the process under termination itself? Hope I expressed myself clearly enough :) -- Christoph

    C 1 Reply Last reply
    0
    • K Krischu

      In the vein of my CreateProcess() question in a parallel thread today I'm facing the problem of letting the called subprocess doing some tidying up work before really following the termination signal. Would that be possible? Or would it be better to send the process a different signal (in UNIX that would have been a USR signal) and wait a time period for receiving the termination event and if that does not occur in time, then terminating it brute force? Is the TerminateProcess an unconditional signal that cannot be intercepted by the process under termination itself? Hope I expressed myself clearly enough :) -- Christoph

      C Offline
      C Offline
      Covean
      wrote on last edited by
      #2

      Have you control about the subprocess? If so why not use named events? HANDLE hEvent = CreateEvent(NULL, true, false, "some_silly_name_you_can_refer_to_in_your_processes"); You can use this in your service and your subprocess. If an event with this name does not exists in the system it will be created, if it exists, you get the same handle as the first application who called CreateEvent with this name. Now you can interact with your subprocesses.

      Greetings Covean

      K 1 Reply Last reply
      0
      • C Covean

        Have you control about the subprocess? If so why not use named events? HANDLE hEvent = CreateEvent(NULL, true, false, "some_silly_name_you_can_refer_to_in_your_processes"); You can use this in your service and your subprocess. If an event with this name does not exists in the system it will be created, if it exists, you get the same handle as the first application who called CreateEvent with this name. Now you can interact with your subprocesses.

        Greetings Covean

        K Offline
        K Offline
        Krischu
        wrote on last edited by
        #3

        Covean wrote:

        Have you control about the subprocess? If so why not use named events? HANDLE hEvent = CreateEvent(NULL, true, false, "some_silly_name_you_can_refer_to_in_your_processes");

        Thanks. Yes, I have control of the process' source code. Will try something in that vein. -- Christoph

        C 1 Reply Last reply
        0
        • K Krischu

          Covean wrote:

          Have you control about the subprocess? If so why not use named events? HANDLE hEvent = CreateEvent(NULL, true, false, "some_silly_name_you_can_refer_to_in_your_processes");

          Thanks. Yes, I have control of the process' source code. Will try something in that vein. -- Christoph

          C Offline
          C Offline
          Covean
          wrote on last edited by
          #4

          In general I do not post my own code but doing some IPC-stuff is not such a secret.   :laugh: Here is a dll I wrote to communicate between 2 apps. The one site calls       GetFaceDetectionStatusChangedEventHandle(),       CreateFaceDetectionStatusMapFile(),       and GetCurrentFaceDetectionStatus() and closes it if it doesnt need it anymore. the other site calls SetFaceDetectionStatus() instead of GetCurrentFaceDetectionStatus(). This code shows how to wait in one app for another and how to transfer data from one app to the other by using shared memory. Note: I left the german comments in for you. ------------------------------------------------------------------------------------------ fdinterop.h

          #pragma once
          #define WINVER 0x0501
          #define _WIN32_WINNT 0x0501
          #define _WIN32_WINDOWS 0x0410
          #define _WIN32_IE 0x0600
          #define WIN32_LEAN_AND_MEAN

          #include <windows.h>

          ////////////////////////////////////////////////////////////////////////////////////
          // Konstanten //////////////////////////////////////////////////////////////////////
          ////////////////////////////////////////////////////////////////////////////////////

          TCHAR szEventName[]=TEXT("FDInteropDllFaceDetectionStatusChanged");
          TCHAR szMapFileName[]=TEXT("FDInterOpDLLFaceDetectionMapFile");

          ////////////////////////////////////////////////////////////////////////////////////
          // Strukturen //////////////////////////////////////////////////////////////////////
          ////////////////////////////////////////////////////////////////////////////////////

          // FaceDetectionStatus Hauptobjekt
          typedef struct _fdsObject
          {
               DWORD     dwTimeStamp;
               BOOL     bFaceDetected;
               INT          nX1;
               INT          nY1;
               INT          nX2;
               INT          nY2;
          } FDS_OBJECT, *PFDS_OBJECT, NEAR *NPFDS_OBJECT, FAR *LPFDS_OBJECT;

          ////////////////////////////////////////////////////////////////////////////////////
          // exportierte Funktionen //////////////////////////////////////////////////////////
          ////////////////////////////////////////////////////////////////////////////////////

          // Gibt das Handle auf das systemweite, b

          K 1 Reply Last reply
          0
          • C Covean

            In general I do not post my own code but doing some IPC-stuff is not such a secret.   :laugh: Here is a dll I wrote to communicate between 2 apps. The one site calls       GetFaceDetectionStatusChangedEventHandle(),       CreateFaceDetectionStatusMapFile(),       and GetCurrentFaceDetectionStatus() and closes it if it doesnt need it anymore. the other site calls SetFaceDetectionStatus() instead of GetCurrentFaceDetectionStatus(). This code shows how to wait in one app for another and how to transfer data from one app to the other by using shared memory. Note: I left the german comments in for you. ------------------------------------------------------------------------------------------ fdinterop.h

            #pragma once
            #define WINVER 0x0501
            #define _WIN32_WINNT 0x0501
            #define _WIN32_WINDOWS 0x0410
            #define _WIN32_IE 0x0600
            #define WIN32_LEAN_AND_MEAN

            #include <windows.h>

            ////////////////////////////////////////////////////////////////////////////////////
            // Konstanten //////////////////////////////////////////////////////////////////////
            ////////////////////////////////////////////////////////////////////////////////////

            TCHAR szEventName[]=TEXT("FDInteropDllFaceDetectionStatusChanged");
            TCHAR szMapFileName[]=TEXT("FDInterOpDLLFaceDetectionMapFile");

            ////////////////////////////////////////////////////////////////////////////////////
            // Strukturen //////////////////////////////////////////////////////////////////////
            ////////////////////////////////////////////////////////////////////////////////////

            // FaceDetectionStatus Hauptobjekt
            typedef struct _fdsObject
            {
                 DWORD     dwTimeStamp;
                 BOOL     bFaceDetected;
                 INT          nX1;
                 INT          nY1;
                 INT          nX2;
                 INT          nY2;
            } FDS_OBJECT, *PFDS_OBJECT, NEAR *NPFDS_OBJECT, FAR *LPFDS_OBJECT;

            ////////////////////////////////////////////////////////////////////////////////////
            // exportierte Funktionen //////////////////////////////////////////////////////////
            ////////////////////////////////////////////////////////////////////////////////////

            // Gibt das Handle auf das systemweite, b

            K Offline
            K Offline
            Krischu
            wrote on last edited by
            #5

            Thanks a lot. I will look into it. -- Christoph

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups