Intercepting the TerminateProcess event
-
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
-
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
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
-
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
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
-
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
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
-
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