Process Group question

I have an MFC based (gui) app, that creates anonymous pipes to a console app that it communicates with.  I have to be able to kill off the console app from the MFC app if the console app gets hung.  This works fine if I communicate directly with the console app, because I can call TerminateProcess() to kill it off if need be.  However, I need to implement support for a console app that has a pre-processing front-end app.  Basically, this pre-processing app parses through the work load, and determines the proper console app to start up to process the work load.  So I need to do this: use CreateProcess() to execute the pre-processing app (which is a console app as well), and that process in turn executes another process.  HOWEVER, if I kill off the pre-processing app, it leaves the workload-processing console app hanging around in the background.  Is there a way to kill off the pre-processing app along with any child processes?  The concept I'm talking about here is a process group.  I tried using CreateProcess() with the CREATE_NEW_PROCESS_GROUP flag, and then using GenerateConsoleCtrlEvent() to send a CTRL_BREAK event to the pre-processing app, but it doesn't work for me.  Any ideas?

-Matt Smith
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Isn't that basically the same as you asked in  ?
<<Only those processes in the group that share the same console as the calling process receive the signal. In other words, if a process in the group creates a new console, that process does not receive the signal, nor do its descendants>>

GUI has no console, so your console apps do not receive the signal.

Before creating console processes, you have to allocate console in the GUI app:



Sleep(100); // May be useful.


// Do not allocate the new console.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
matthewsmithAuthor Commented:

Yes, I did ask the same question before.  I'm not sure why it says 'accepted answer', because I don't remember accepting it, and it certainly didn't ever work for me.

To NickRepin:

I was thinking along those lines.  This sounds like a reasonable solution.  I'll try implementing it tomorrow morning and let you know.  Thanks!

-Matt Smith
I tested it before I posted the answer here.
matthewsmithAuthor Commented:
One other problem I'm having Nick: Everything works fine with the process group, but when I call AllocConsole(), it shows the console window.  Can I have it be hidden some how?  Thanks!

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Development

From novice to tech pro — start learning today.