S
S
slinkinone2018-11-04 15:56:00
C++ / C#
slinkinone, 2018-11-04 15:56:00

What are the PIC methods in Windows?

Good day to all!
I ran into a problem, I will describe step by step :

  1. I create a console ( PARENT ) application. In implementation, it creates several child processes.
  2. Child processes ( CHILD s) write logs (as an example), as a result, after the completion of these processes, it is necessary that they clean up these files after themselves. Naturally, there are special functions for deleting files.
  3. After the MAIN process has completed its work, it needs to tell the daughters what to clean up after themselves, after which they can be terminated.

Actually the problem is that I can’t implement the correct completion of the main process with all the daughters. As I understood, SetConsoleCtrlHandler and GenerateConsoleCtrlEvent can help with this, by generating CTRL_BREAK_EVENT from MAIN for daughters.
If anyone has a working example, please share.
If you have any suggestions, I'm willing to listen.
Thank you!
PS : Just in case, I am attaching my code (not very clean, because I used it for debugging).
Brief description, in it I create the following process tree:
ROOT
----|___Parent
--------|____Child
In Childprocess I set handler for processing of a signal/message from the parent.
After launch, press Any key to create Parent .
Then in the P a rent window, press Any key to create a Child process.
Then click in the Parent window again Any key to generate a signal for the Child . We see that the handler in the Child process did not work. Link to code ( pastbin ):

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
res2001, 2018-11-04
@res2001

You have child processes hanging on system("pause"); and do not end on their own.
Just delete this command in daughters, leave it only in the main process and you won't have to stir up anything with CTRL_BREAK.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question